[SOLVED] Custom delegate "createEditor" never gets called
-
Good day everyone,
Firstly, I can edit my view without the delegate without any issues (i.e. my "flags()" and "setData()" methods seem to be implemented correctly).
Secondly, I set the delegate on the view itself via "setItemDelegate()"
Thirdly, I have confirmed that the delegate's "setEditorData()" and "setModelData()" methods get hit every time I attempt an edit, but the "createEditor()" method is never, ever called.
Since I've just started playing with the Model/View/Delegate idea, I have a little "playground" project where I am testing these concepts in an attempt at understanding them. The project and all the code (there isn't much) is available "here":https://www.dropbox.com/sh/k2psfo56gm1emea/AACQubfSiZeawiIPwyOvqbWXa?dl=0
Any help will be appreciated :)
Thanks!
-
There is mismatch in the signature of createEditor. Please look at the warnings. It says virtual createEditor(...) is hidden by your createEditor(...). So your createEditor is different from virtual createEditor(...).
Just try the following.
@QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QWidget *DomDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const {qDebug() << "I am here-Delegate"<<endl;
QPlainTextEdit *textEdit = new QPlainTextEdit(parent);
//QSpinBox *box = new QSpinBox(parent);
return textEdit;
//return box;
}@ -
Wow, what a noob error :D
Thank you for that Dheerendra, you are indeed correct, but I am not receiving any warnings...will look into the why of it...
-
OK, no idea why, but it seems the standard "Desktop Qt 5.3.0 GCC 64bit" kit that comes with Qt Creator does not pick these issues up. Switched to Clang and much happiness is being had all around.
Thanks again!