[問題] Qt tableview w/i spinbox and combobox
最近在改寫spinbox的範例
http://doc.qt.nokia.com/4.7-snapshot/itemviews-spinboxdelegate.html
試著改成第一個column為combobox第二個column為spinbox
目前用第一種方式可以成功
但google時又看到另一種,不知道兩個方法有什麼差別呢?
各有甚麼優缺點呢?
第一種:在createEditor,setEditorData,setModelData加if隔開
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
if(index.column()==1)
{
QSpinBox *editor = new QSpinBox(parent);
editor->setMinimum(0);
editor->setMaximum(100);
return editor;
}
else
{
QComboBox &editor =new QComboBox(parent);
....
}
}
第二種:用paint,目前還沒有試(不好意思不會縮網址)
如http://stackoverflow.com/questions/2766873
/how-to-insert-qpushbutton-into-tableview
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.243.158.70
→
06/08 02:10, , 1F
06/08 02:10, 1F
→
06/08 02:11, , 2F
06/08 02:11, 2F
→
06/08 13:57, , 3F
06/08 13:57, 3F
→
06/10 21:39, , 4F
06/10 21:39, 4F
→
06/10 21:40, , 5F
06/10 21:40, 5F
→
06/10 21:41, , 6F
06/10 21:41, 6F
※ 編輯: tata111 來自: 1.169.132.24 (06/10 21:43)