QSystemTrayIcon on Windows11
Solved
General and Desktop
-
Hi,
With the QSystemTrayIcon class I can display messages as banners in Windows 11. But as soon as the timeout hint is over, the banner disappears, but the message is not displayed in the notification list. However, it is activated in the Windows settings.If I open the notification list and send a message, it appears in the list. But only as long as the list is open. As soon as the notification list is closed, the message disappears again.
#include <QApplication> #include <QSystemTrayIcon> #include <QTimer> #include <QStyle> int main(int argc, char *argv[]) { QApplication a(argc, argv); QSystemTrayIcon systemTrayIcon; systemTrayIcon.setIcon(QApplication::style()->standardIcon(QStyle::SP_ComputerIcon)); systemTrayIcon.show(); QTimer timer; timer.setSingleShot(true); QObject::connect(&timer, &QTimer::timeout, [&systemTrayIcon]() { systemTrayIcon.showMessage("My Title", "My Message"); }); timer.start(0); return a.exec(); }
Using Qt 5.15 and Qt 6.6.2
EDIT:
The problem occures also in the official shell api example by Microsoft: https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/Win7Samples/winui/shell/appshellintegration/NotificationIconFound WinToast which works fine!
-
B beecksche has marked this topic as solved on