c++qtqsystemtrayicon

How to make decorated rich popup window instead the default QSystemTrayIcon popup window


I have a simple notification application, and I'm using Qt 4.7.1 with C++ to write an application that sits in the system tray. Every time a message comes; I need it to pop up a window, with rich content (i.e., I want to add color and pictures to it).

However, all I have is the default pop-up message box. How can I create a new, richer one that will always pop up above the tray icon?


Solution

  • All Qt widget classes can be styled via stylesheets, depending on where create your popup (designer, or in code) assign it a stylesheet with the look that you want it to have. You can test stylesheets in designer by assigning a style to a widget using the context menu of the widget.

    After further review, the QSystemTrayIcon::showMessage() call puts up a system notification. Which I don't know if it can be styled. The qsystemtrayicon_win.cpp file in the qt distribution shows a workaround and shows a way of how to find the location of the icon in the tray (see QSystemTrayIconSys::findIconGeometry). Once you have the location, you could pop up your own window at that location. I did not look too deep, I don't know if you can get to the location for the icon with the information that you have on the public side of Qt. You might have to go all windows with that.