Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] Bouncing Tray Icon at Program Start
Is there a way to prevent the bouncing program icon when a program starts?
Something simple I'm missing maybe...like a checkbox I could choose to enable/disable in Qt Creator?
Maybe assign the program's window icon to a null or invisible icon file?
andre last edited by
That's a feature of whatever OS you are on. It has nothing to do with your application. The only way to prevent it from happening, is to make sure your application starts faster.
Rahul Das last edited by
What tray icon bouncing ? I don't have any :(
[quote author="Rahul Das" date="1323714173"]What tray icon bouncing ? I don't have any :([/quote]
Probably a dock icon was meant. At least that's used on the Mac.
Yes.."Dock Icon" on a Mac
The same icon is defined in the .pro file per the Qt docs.
ICON = theIconToSet.png
The app icon is being set as soon as is allowed. It can't be set prior to the "QApplication a(argc, argv);" statement in the code below.
I'm not sure how the app could start any quicker...
This the code being executed prior to setting the app icon.
int main(int argc, char *argv)
QApplication a(argc, argv);
a.setWindowIcon( QIcon(":/Icons/theIconToSet.png") ); MainWindow w; //w.show(); //QTimer::singleShot(2000, &a, SLOT( quit() )); return a.exec();
You need to set the application icon for the bundle itself. Looking at the finder, your application shouldn't have a decent icon too, but the standard icon showing a sheet of "paper" and some tools forming an upper case "A".
To set the application's icon for the finder (and the dock), you must put it into an icons resource and add it to your .pro file:
macx:RC_FILE = yourapp.icns
Please have a look in the nets on how to create that icns file.+
Oh, sorry. I overlooked that you did that step already.
So, what is exactly your problem now?
I'm still seeing the "standard icon" (IE: showing a sheet of “paper” and some tools forming an upper case “A”) just before the "real" icon defined in the resource file is displayed in the dock.
Granted, it's only a very brief flash of the "standard icon" when the icon is first added to the dock at program start, but it's visible.
When the app shuts down, the "standard icon" reappears and shrinks down to nothing before eventually disappearing.
Using the ICON variable works for me too (I usually use RC_FILE for the Mac for historic reasons).
Maybe your icns file is corrupted. Did you try to use one of the files provided with the Qt sources for testing? This way you can be sure to have a working icns file at least.
OK, I used the apple supplied Icon Composer to look at a few of the icns files you listed and most had all the Icon sizes defined..512,256,128,32,16.
The icns file I'm using only has 32 and 16. I'll try filling the other slots in the icon file I'm using and see if that makes a difference.
OK, this is really weird..so maybe there's a logical explanation that someone who knows more about Apple/Mac development than I do (which wouldn't take much).
I went through all the changes suggested above. Recreated the .icns files using IconComposer. Manually edited the plist file in the App bundle. Cleaned & Rebuilt the project. Did them all again to make sure I didn't miss something or mess something up. Opened some Apple App Bundles to see how their plist and resource stuff was defined making sure that my app bundle looked similar.
No Change. Still had the dang Default icon. I could force the app to show the desired icon with the "app.setWindowIcon( )" method, but there was still an annoying delay as the app started where the Default Icon displayed and the "Real" icon loaded.
I got so frustrated that I clicked on the App Bundle in the Qt dev directory and tried to drag it to the Trash but missed, landing the App Bundle on the Mac desktop instead.
Bing! As if by magic, the "real app icon" appeared replacing the "default". In amazement, I clicked on the icon to start the app. No Default Icon. The actual app icon now shows in the dock and grows and shrinks as "normal" or "expected".
I dragged the App Bundle back to the Qt Dev directory and the "Real Icon" is still displayed. Everything still works as expected.
I don't know why it's working, but it is.
I added the "ICNS =" statement to the .pro file
I made sure the .icns file was not bad. (currently the .icns file that is working only has the 32 and 16 sizes defined.
I put the .icns file in the same directory as the .pro file.
I put the .icns file in the app bundle Resource sub-directory. The .icns file is NOT listed in the project .qrc file.
The act of dragging the App Bundle out of the development directory is apparently what did something that allowed the real, desired icon to be displayed and used correctly.
Maybe a Mac-o-phile can explain why this works?
I can be that the OS X Finder does some caching on the icons. Sometimes it can help to delete the application bundle and just recreate it.
Glad to see that it works now!
Hedge last edited by
Even though this problem has been solved a long time ago I'd like to add that you can refresh Finder's view on .app-folders (including options set in the Info.plist) by executing touch on the .app-folder.