Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt App Icon will only show on certain PCs
Qt 6.11 is out! See what's new in the release blog

Qt App Icon will only show on certain PCs

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.3k 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.
  • C Offline
    C Offline
    cl90
    wrote on last edited by
    #1

    Hello!

    I use QT 5.2.1 with QtMSVCAddin 5.2.1
    (I only use the ui designer from Qt, the rest is done in MSVC 2012)
    and have a Problem with displaying an Application Icon on some PCs.

    I set the icon resources in MSVC as usual with an rc file:
    "IDI_ICON1 ICON DISCARDABLE "icon1.ico""
    With this, the .exe file (in explorer) will show the icon correctly on every tested PC.
    BUT: The icon next to the appliccation-title and also the icon in the taskbar is still the default icon.

    So somehow the qt stuff overwrites my icon which was set in the rc file.
    Why, and where can i fix it?

    furthermore i added the same icon through the ui designer from qt.
    and somewhere in the genereated sourcecode this lines show up:
    QIcon icon;
    icon.addFile(QStringLiteral("icon1.ico"), QSize(), QIcon::Normal, QIcon::On);
    this->setWindowIcon(icon);
    The funny part is. with this lines, only systems with Qt installed can display the icon (in title and bar)
    Also the icon1.ico file must be beside the .exe file, which is pretty ugly.

    anyway to help me?
    i cant be the only one with this Problem =(

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can use Qt's resource system to embbed the icon within your application. Also, did you check that you deployed all the required imageformat plugins with your application ?

      On what version of windows does it happen ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cl90
        wrote on last edited by
        #3

        How would i insert the icon to the Qt's resource system?

        Is there a dll i have to place beside the .exe for icon Applications?

        Every testet System is win7.
        The Software does not need to be downwards compatible.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cl90
          wrote on last edited by
          #4

          I found out how to add and use .qrc files with qt Projects, and learnt that my Qt does not seam to work right.

          Because somehow my res.qrc never get compiled by the rcc.exe.
          No Files where created in any way.

          This is my .pro:
          @
          #-------------------------------------------------

          Project created by QtCreator 2015-02-25T16:00:14

          #-------------------------------------------------

          QT += core gui

          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

          TARGET = qtico
          TEMPLATE = app

          SOURCES += main.cpp
          qtico.cpp

          HEADERS += qtico.h

          FORMS += qtico.ui

          RESOURCES +=
          res.qrc
          @
          ###########################################

          This is my res.qrc File:
          @
          <RCC>
          <qresource prefix="/">
          <file>logo.png</file>
          <file>icon.ico</file>
          </qresource>
          </RCC>
          @
          #########################################

          This is the code which should load the logo from the ressource:
          (This time no Icon. But if i Fix this problem i may fix the Icon problem)
          @
          QImage image("qrc:/logo.png");
          if(!image.isNull()) {
          ui->label->setPixmap(QPixmap::fromImage(image));
          ui->label->show();
          }
          @

          [edit: added missing coding tags @ SGaist]

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            IIRC you should not put qrc in front of your resource path only :/

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • C Offline
              C Offline
              cl90
              wrote on last edited by
              #6

              Tried it with, without and a thousand other ways i found in some forums.
              Non of them works.

              But lets stick to the Problem.
              What should happen to a .qrc file?
              No file where generated when i run the program except other stuff.
              I dont even try to do it with MSVC. its a pure new Qtonly app.
              And i cant figure out how to get ressources work.

              1 Reply Last reply
              0
              • bagavathikumarB Offline
                bagavathikumarB Offline
                bagavathikumar
                wrote on last edited by
                #7
                1. Create the rc file with below content in the same path

                @IDI_ICON1 ICON DISCARDABLE "icon1.ico"@

                1. Insert the rc file into the project file

                @win32:RC_FILE += abc.rc@

                1. Clean the project and run.
                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