[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?



  • 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.



  • 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.

    @
    #include <QtGui/QApplication>
    #include "mainwindow.h"

    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&#40;&#41;;
    

    }

    @



  • 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.+

    EDIT
    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.

    ./demos/browser/browser.icns
    ./demos/qtdemo/qtdemo.icns
    ./tools/assistant/tools/assistant/assistant.icns
    ./tools/designer/src/designer/designer.icns
    ./tools/designer/src/designer/uifile.icns
    ./tools/linguist/linguist/linguist.icns
    ./tools/qdbus/qdbusviewer/images/qdbusviewer.icns
    ./tools/qml/qml.icns



  • 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.

    Recapping..

    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!



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.