PDA

View Full Version : Question re QCheckBox and delegate



vieraci
22nd June 2009, 08:35
If I wanted to intercept the click event on a QTreeView holding QStandardItems, where would the best place to catch it ?

I don't want the QItemDelegate::createEditor() function to create a check box, rather I want the delegate to ignore it and to set or clear the displayed one that QStandardItemModel::data() shows with either a single or double-click.

e8johan
22nd June 2009, 08:52
Since the delegate does not have that ability, I suppose that you have to subclass the view.

vieraci
22nd June 2009, 09:28
setEditTriggers(QAbstractItemView::NoEditTriggers) affects the whole view.
Can't a single column be singled out ?

wysota
22nd June 2009, 09:43
How about connecting to the QAbstractItemView::clicked() signal?

vieraci
22nd June 2009, 10:16
Yeah, sure. I've already considered it, that's an easy solution, but a bit of a hack isn't it ? If it's the only option then there remains one last question. How to block the delegate from receiving any further signal. I guess setEditorData is the logical place, but you have to return an object... or do you ?

edit: I meant createEditor(), not setEditorData()

wysota
22nd June 2009, 10:52
What's so hackish in using a signal for things it is meant to be used for? Maybe I don't see what your problem is... could you elaborate on it? The checkbox you see in the view is not created by the delegate's createEditor() method. There is no real checkbox there - the delegate draws the checkbox and handles clicking on it through editorEvent(). If you want to check/uncheck the box in some other way, just do it.

vieraci
22nd June 2009, 12:23
the delegate draws the checkbox and handles clicking on it through editorEvent().

Why Thank you wysota, That's the method I was looking for. :o