Results 1 to 3 of 3

Thread: QSystemTrayIcon capture mouse hover event

  1. #1
    Join Date
    Feb 2006
    Location
    de
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSystemTrayIcon capture mouse hover event

    Hi,

    is the above possible?
    QSystemTrayIcon shows a nice tooltip when the mouse hovers over the tray icon.
    However, it's the currently played song on a mpd (music player daemon).
    I need to query the mpd each time the mouse hovers over the icon.

    So far I could not make the eventFilter example in Qt 4.5.2 work:

    *.h
    bool eventFilter( QObject *obj, QEvent *ev );

    *.cpp
    bool xxxx::eventFilter( QObject *obj, QEvent *event )
    {
    cout << "eventFilter(): reached ! " << endl; // debug
    if( event->type() == QEvent::HoverEnter ) {
    emit sigSendCmd( xy ); // this will query the mpd
    }
    }

    Seems, that I do not catch the mouse hover event at all.
    The cout never triggers.

    Any ideas?
    Is it possible to get the mouse hover enter event with a SystemTrayIcon?
    QSystemTrayIcon is based on QObject directly, but the damn tooltip is shown on mouse over...

    Help much appreciated,
    alan

  2. #2
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSystemTrayIcon capture mouse hover event

    The class reference for QSystemTrayIcon says:

    Only on X11, when a tooltip is requested, the QSystemTrayIcon receives a QHelpEvent of type QEvent::ToolTip. Additionally, the QSystemTrayIcon receives wheel events of type QEvent::Wheel. These are not supported on any other platform.
    So if you are coding for an other platform, you are unlucky. On X11, you should get a ToolTip event.

    An other approach would be to set the toolTip whenever the current song changes or to update the toolTip regularly using a QTimer.

  3. The following user says thank you to shentian for this useful post:

    alan (1st August 2009)

  4. #3
    Join Date
    Feb 2006
    Location
    de
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSystemTrayIcon capture mouse hover event

    Thanks shentian,

    I should read more carefully in the future.

    I choose to capture the (main) event. Did not want to create a poll timer for the rare cases this function is used. But it is working now. :-)

    alan

Similar Threads

  1. Hover on mouse over while dragging
    By mooreaa in forum Qt Programming
    Replies: 3
    Last Post: 6th February 2010, 10:31
  2. how to send a emulated mouse event to QListWidget
    By yxmaomao in forum Qt Programming
    Replies: 4
    Last Post: 22nd July 2008, 02:49
  3. pass mouse event information to another widget
    By Rooster in forum Qt Programming
    Replies: 5
    Last Post: 12th July 2008, 04:23
  4. Replies: 1
    Last Post: 4th February 2008, 11:12
  5. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05

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.