[Qt-interest] Mouse events inside item view delegates

Andre Somers andre at familiesomers.nl
Sun Aug 22 10:43:22 CEST 2010


  Op 22-8-2010 0:16, Neville Dastur schreef:
> Hi
>
> I don't know if someone can help me. I have a QTreeView and for one of
> the columns I set a custom delegate. This delegate paints a number of
> icons in a row, within that column, representing buttons.
>
> Now I want to be able to detect a mouse click on my custom delegate and
> determine the position within the item so that I know which item has
> been "clicked"
>
> For the life of me a and plenty of searching I can't find out how to do
> this.
>
>   From within the on_treeView_clicked(QModelIndex *i) slot I can find a
> way of getting mouse coordinates relative to the item and the
> MouseRelease event doesn't seem to get called at all.
Did you look at letting the delegate handle the mouse interaction?
See QAbstractItemDelegate::editorEvent

André




More information about the Qt-interest-old mailing list