简体   繁体   中英

Qt: how to make decorated rich popup window instead the default QSystemTrayIcon popup window

I have 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. But, I need it to be rich (ie, I want to add color and pictures to it). However, all I have is the default pop-up message box. How can I create new richer one that will always pop-up above the tray icon?

All the qt widget classes can be styled via stylesheets , depending 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 to 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM