Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] Can't set the window icon for QML application
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Can't set the window icon for QML application

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 2 Posters 15.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    portoist
    wrote on last edited by
    #2

    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.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Lucijan
      wrote on last edited by
      #3

      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?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        portoist
        wrote on last edited by
        #4

        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

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Lucijan
          wrote on last edited by
          #5

          Still can't get it to work. Are you running it from Qt Creator or directly from the .exe?

          1 Reply Last reply
          0
          • P Offline
            P Offline
            portoist
            wrote on last edited by
            #6

            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.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              Lucijan
              wrote on last edited by
              #7

              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?

              1 Reply Last reply
              0
              • P Offline
                P Offline
                portoist
                wrote on last edited by
                #8

                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.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  Lucijan
                  wrote on last edited by
                  #9

                  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.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    portoist
                    wrote on last edited by
                    #10

                    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,

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Lucijan
                      wrote on last edited by
                      #11

                      It works so I don't dare mess with it further. Marking this as solved.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved