2012-07-17 34 views

回答

3

我假設你已經重新實現QAbstractItemDelegate::createEditor()

最簡單的方法,以表明在表中的某個指標應該爲可編輯就是從這個函數返回NULL,例如:

QWidget *QAbstractItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) 
{ 
    if(index.column() == 0) 
    return NULL; 

    return new QSpinBox(parent); 
} 

你可以在你的模型塞進更多的信息,並與QModelIndex::data()

+0

該訣竅取回票友。我有點擔心我會通過返回一個空指針來崩潰程序......我沒有意識到'QAbstractItemDelegate'足夠聰明來檢查它。謝謝! – 2012-07-17 19:52:06

相關問題