Results 1 to 10 of 10

Thread: Capture events in a custom delegate

  1. #1
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Capture events in a custom delegate

    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?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Capture events in a custom delegate

    Quote Originally Posted by vfernandez View Post
    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()?
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Capture events in a custom delegate

    You'll get editor events which you can handle in the editorEvent of the item delegate. You can open the link from there.

  4. The following user says thank you to wysota for this useful post:

    vfernandez (28th March 2007)

  5. #4
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Capture events in a custom delegate

    Thanks. After enabling mouse tracking in the view I receive the events in editorEvent().

  6. #5
    Join Date
    Feb 2008
    Posts
    60
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Capture events in a custom delegate

    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.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Capture events in a custom delegate

    Handle the mouse release event through the delegate or use the view's clicked() signal.

  8. #7
    Join Date
    Feb 2008
    Posts
    60
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Capture events in a custom delegate

    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.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Capture events in a custom delegate

    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.

  10. #9
    Join Date
    Feb 2008
    Posts
    60
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Capture events in a custom delegate

    once again thanks for your reply.

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

    Thank you.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Capture events in a custom delegate

    You have to calculate that yourself. QFontMetrics::boundingRect() might be helpful.

  12. The following user says thank you to wysota for this useful post:

    jay (19th March 2008)

Similar Threads

  1. Replies: 1
    Last Post: 13th July 2006, 21:10
  2. Posting custom events to a subclass of QThread
    By jpn in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2006, 15:49
  3. [Qt4] Noob and custom Item Delegate
    By naresh in forum Newbie
    Replies: 36
    Last Post: 19th March 2006, 15:46
  4. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.