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
Re: QSystemTrayIcon capture mouse hover event
The class reference for QSystemTrayIcon says:
Quote:
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.
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