QSystemTrayIcon accumulates
-
Hi
Windows 7
Qt 5.3.0 mingwI use the following code to show tray icon, but it stays there even after I close my application, they clear only when I hover over them, what wrong am I doing?
@
QSystemTrayIcon *icon = new QSystemTrayIcon(QIcon(":/icons/logo.png"));
if(icon->isSystemTrayAvailable()){
icon->show();
icon->showMessage(tr("Help"), tr("Help text"), QSystemTrayIcon::Information, 2000);
}
@ -
Hi,
Since you did not give a parent to your QSystemTrayIcon, are you deleting it somewhere ?
-
Thanks for the quick response SGaist!
No, should I use (this) as parent?
@
QSystemTrayIcon *icon = new QSystemTrayIcon(QIcon(":/icons/logo.png"), this);
@
I am creating the icon in the main class of type (MainWindow).PS: I have posted the same by mistake in other forum (Cloud), I could not deleted it, sorry.
-
Indeed you should. Without that you have a memory leak and icon will not be properly destroyed when your program ends
-
Thanks, it worked nicely.
-
You're welcome !
Since it's now all working fine, please update the thread title prepending [solved] so other forum users may know a solution has been found :)