PDA

View Full Version : Check what EditTrigger triggered the QStyledItemDelegate



torres
12th April 2011, 15:18
I have a custom delegate class that inherits from QStyledItemDelegate.
Is it possible to know in createEditor() of the delegate, what action triggered the delegate?
If it's double click I would like to have a LineEdit pop up. QAbstractItemView::CurrentChanged and QAbstractItemView::SelectedClicked should result in showing a button.

Thanks

wysota
12th April 2011, 15:35
No, createEditor() is not a right place to detect such things. You can probably catch that in editorEvent() as different triggers are caused by different events.

torres
12th April 2011, 21:36
No, createEditor() is not a right place to detect such things. You can probably catch that in editorEvent() as different triggers are caused by different events.
I read somewhere in the documentation that there's either the createEditor approach or using editorEvent().
Then I have to get rid of the createEditor() function? How would I draw the custom LineEdit widget and the button that I return up to now in createEditor?

wysota
12th April 2011, 23:17
I read somewhere in the documentation that there's either the createEditor approach or using editorEvent().
It's not that simple. You can use both if you want.


Then I have to get rid of the createEditor() function?
No. Determine the trigger in editorEvent() and then use that knowledge in createEditor().