Update tooltip of QSystemTrayIcon when displayed
-
Hi all,
I'm using a QSystemTrayIcon widget in my app. I noticed that if the tooltip is already displayed then the text is not updated until I move out the mouse and move it again on the tray icon.
Is there a way to update the content of a tooltip of the QSystemTrayIcon when it is already displayed? -
Hi and welcome to devnet,
On which platform are you seeing that ? Which version of Qt are you using ?
-
@SGaist
Hi and thank you for the reply.
Actually I'm working on a crossplatform desktop app on Windows and Mac with Qt 5.5. -
Are you seeing that behavior on both OSs ?
Which version of the OSs are you using ?
-
Yes the behaviour is the same on both platform (OSX 10.11.3 and Windows 10 with the latest updates).
As far as I understood, QSystemTrayIcon tooltip is not using QToolTip but it relies on the tooltip provided by the os which has some limitation.
I'm not able to find a proper event/method to override in order intercept the tooltip handling and use a QToolTip. -
You can try to reimplement the event method and check there for the QToolTip event.
-
That is what I tried but I didn't receive any event :(
From the official documentation:
"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." -
I missed that bit of the doc. Then, you're pretty much out of luck outside trying to modify Qt but that doesn't mean there's any support for that use case natively.
Out of curiosity, why do you need to do that ?
-
I'm going to download/upload files so I would like to show the percentage and remaining time in the tooltip
-
The tooltip isn't necessarily the best tool to show such dynamic data. You should maybe have that information on a dialog that you open on a mouse click. And just show a rough estimate in the tooltip.
-
@SGaist
I agreed with you, tooltips are not concerned for this kind of info but the product owner was not of the same idea :D -
Take for example the DropBox client, it's on the widget associated to the system tray icon that you will find this kind of information.