Results 1 to 2 of 2

Thread: QT 4.3.3: QSystemTrayIcon, winEvent, how to add an on ON HOVER handler...

  1. #1
    Join Date
    Feb 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QT 4.3.3: QSystemTrayIcon, winEvent, how to add an on ON HOVER handler...

    Hi,

    I've been working with the QSystemTrayIcon component, this part of our
    application is targeted towards windows exclusively, so I don't mind if
    I do something that is not portable.

    QSystemTrayIcon emits a number of button activated reason codes via its
    "activated" signal, but I am trying to capture the event that signals
    that the mouse is hovering over the tray icon, specifically in windows,
    the WM_NCMOUSEHOVER event.

    I've gone through the source of QSystemTrayIcon to see how its private
    parts work, but I can't quite seem to figure out an appropriate (or the
    best) way to capture WM_MESSAGE traffic in my tray applet, and if I
    don't see the one message I am after, delegate it back down to the
    QSystemTrayIcon object I am a decedent of. It seems that all pretext of
    the QWidget is deeply nested inside of private classes that I can
    dispatch to from my derived object.

    Is there something I am missing? I can modify the
    QSystemTrayIconSys::winEvent in qsystemtrayicon_win.cpp to do what I
    want it to, but I don't want to be off in a private branch for my QT
    source... I've tried all the ticks I can think of in my derived
    QSystemTrayIcon class, but alas, it does not directly inherit from
    QWidget and doing so, I still can't dispatch down my inheritance chain
    to handle those things that I don't need to.

    Thanks

    John Suykerbuyk

  2. #2
    Join Date
    Apr 2006
    Location
    Denmark / Norway
    Posts
    67
    Thanks
    3
    Thanked 12 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QT 4.3.3: QSystemTrayIcon, winEvent, how to add an on ON HOVER handler...

    You can do an winEvent, but have a look at QWidget::enterEvent, as this tells you when the mouse enters the widget, you can do something similar with ordinary event and QEvent::MouseMove.

    This makes the tricky part, as you can do a custom class with a subclass of QWidget and QSystemTrayIcon. (which I don't know if would work...)

    But the easier solution is probably to reimplement ::event(QEvent*e)
    Somthing linke this:

    Qt Code:
    1. bool SystTrayIcon::event( QEvent e )
    2. {
    3. switch ( e->type() ) {
    4. case QEvent::MouseMove:
    5. /*
    6.   Do Mouse Move stuff Here
    7.   Should happen when the mouse is over your systray icon
    8.   */
    9. break;
    10.  
    11. case QEvent::MouseButtonPress:
    12. /* Button Press things here */
    13. break;
    14. case QEvent::MouseButtonRelease:
    15. / * Do mouse release button stuff */
    16. break;
    17. case QEvent::MouseButtonDblClick:
    18. / * Do mouse double click stuff */
    19. break;
    20. default:
    21. return QObject::event( e );
    22. }
    To copy to clipboard, switch view to plain text mode 

    Have a look at how the systray implements the clicks if you want same functionality as it has for those options.

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.