[SOLVED] Can't set the window icon for QML application
-
I don't know if my solution is right but for me this is working:
In my project root I have file with icon (icon.ico) and file MyProjectName.rc with this line:
@
IDI_ICON1 ICON DISCARDABLE "icon.ico"
@
And in MyProjectName.pro I have:
@
...
RC_FILE = MyProjectName.rc
...
@
Hope it will help!Edit: sorry, I've noticed that you have mentioned trying this solution, what exactly didn't work for you? I am using Win7 x64 with QT 5.0.2 as well and I have tried this and it works just fine for me. Icon is set for .exe file, shown in windows panel, and in window top left corner.
-
The icon is shown for the .exe file but it doesn't show in taskbar nor in the top left corner of the window. It does show if I make a plain Qt GUI application, but not if I make a Qt Quick (QML) application.
Additionally, setting the title using setTitle("bla") works fine. Does the icon need to have some specific properties regarding size, transparency etc? -
I am also running QML app. Maybe there is something wrong with your ico file? I have created an empty QML qt quick 2 project with icon, you can see it "here":https://bitbucket.org/portoist/qml_icon_example/overview
"This is how it works for me":https://www.dropbox.com/s/i2jnsnbw6aa4898/example.PNG -
Still can't get it to work. Are you running it from Qt Creator or directly from the .exe?
-
It should work from Qt Creator as well as from exe.
Did you try to use the ico file from test project I have posted inside your project? Or upload you icon somewhere and I can try to use it - so that we can check if there is something wrong with your icon, or if there something else. -
I tried your icon with the same results, it displays for the .exe file but not for the window.
You can check my icon here:https://www.dropbox.com/s/0b2fnhiaf6y0zp1/DESIGN.ico
In the meantime, could you upload your entire project somewhere so I can try it directly?
-
Your icon works fine for me, "this":https://www.dropbox.com/s/75h3hslb562trna/example2.PNG is what I can see.
I have created app just with hello world window and put it into bitbucket. You can download source code in zip from "here":https://bitbucket.org/portoist/qml_icon_example/get/76c4aa4b206d.zip
Just unzip it and open in Qt Creator, I have added your icon inside. -
OK, I finally got it working. It looks like my .rc file was the problem with the name being too long.
I had this:@IDI_DESIGN_ICON ICON DISCARDABLE "images/icon.ico"@
but the name can only have up to 8 characters, so I changed it to the name you put (IDI_ICON1) and now it works fine. Thanks a lot for your help. Love the use of nyan cat, by the way.
Edit: Maybe a note about this should be added to the documentation.
-
You are welcome, glad that it works.
I have never thought about changing the icon name to anything else, I have just took the line from Qt doc:-) I have played with it a bit and it seems that IDI_ICON1 is the only one working, -
It works so I don't dare mess with it further. Marking this as solved.
11/11