PDA

View Full Version : Capture events in a custom delegate



vfernandez
28th March 2007, 11:09
Is there any way to catch events in a custom delegate without having to subclass the view? I'm creating a delegate and I would like to add some labels that will act as "links" (like in the Download Manager of Firefox). Thus, I need to catch a hover event to change the mouse pointer and a click event to launch the corresponding signal. I've tried reimplementing the editorEvent() method without luck. Any ideas?

jpn
28th March 2007, 11:34
Thus, I need to catch a hover event to change the mouse pointer and a click event to launch the corresponding signal. I've tried reimplementing the editorEvent() method without luck. Any ideas?
As far as I remember, you'll get mouse move events when mouse tracking is enabled on the viewport. Still no hover events, though. Btw, have you noticed signal QAbstractItemView::entered()?

wysota
28th March 2007, 13:16
You'll get editor events which you can handle in the editorEvent of the item delegate. You can open the link from there.

vfernandez
28th March 2007, 14:01
Thanks. After enabling mouse tracking in the view I receive the events in editorEvent().

jay
18th March 2008, 07:36
Dear all,

I am having the same requirement as in this thread.
In my application, Cancel link alone enough, which cancels the current process.

please anyone help me how to find whether this link is clicked (or) the mouse cursor is hover the link?
How the editorEvent() helps to achieve this.

I have drawn the 'Cancel' text using drawText method.
is any other way to implement this?

I am using Qt4.3.3

Thanks in advance.

wysota
18th March 2008, 11:25
Handle the mouse release event through the delegate or use the view's clicked() signal.

jay
18th March 2008, 12:02
Thank you for your reply.

I am using clicked signal and the mouse pointer position for finding the link is clicked or not.

is there is a way to find whether the mouser is hover the link or not.

Thank you.

wysota
18th March 2008, 12:22
You mean whether the cursor is over an item or whether it is over an area covered by the pixels of the link? If the former, then QStyleOptionViewItem object passed in the editor event of the delegate carries such information.

jay
19th March 2008, 02:47
once again thanks for your reply.

I mean the cursor is on the area which is covered by the link.

Thank you.

wysota
19th March 2008, 05:33
You have to calculate that yourself. QFontMetrics::boundingRect() might be helpful.