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. [SOLVED] Display Icon in an .exe File in Qt
QtWS25 Last Chance

[SOLVED] Display Icon in an .exe File in Qt

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 12.9k Views
  • 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.
  • S Offline
    S Offline
    Stoned Jesus
    wrote on last edited by
    #1

    I am working on a Qt app where I need to display some UI and perform operation on them. When i run the application it creates a .exe in my debug/release folder. I want to put the icon in the .exe file rather than a blank icon which appears by default.

    Is their a way one can do it in .ui file or we need to do it programmatically? I am kinda sure I need to use a resource file and store the image there. I tried to search for some more details but couldn't figure out anything related to Qt. Please help :)

    --
    Thanks & Regards,
    Stoned Jesus

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on last edited by
      #2

      "Setting the Application Icon":http://doc.qt.digia.com/qt/appicon.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        It's not clear what you want.

        (1) Display an icon inside your window
        (2) Change the window/taskbar icon of running application
        (3) Change the EXE files icon, as shown in explorer

        Solutions:

        (1) Use QIcon in conjunction with a QLabel and QLabel::setPixmap(). This can be done completely in the Qt Designer using a .ui file: Just add a QLabel and set its Pixmap property.
        (2) Use QWidget::setWindowIcon(), again in conjunction with a QIcon.
        (3) Not really in the scope of Qt. You need to add the icon as a resource to your EXE file, but not using Qt's resource system; use a Visual Studio .rc/.res file.

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

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

          [quote author="cincirin" date="1355403283"]"Setting the Application Icon":http://doc.qt.digia.com/qt/appicon.html[/quote]

          The instructions in "Setting the Application Icon on Windows" surely is the right way but based from experience, it only works when using msvc2008 in Qt4.8.3 (mingw and msvc2010 outputs error, IDK why? maybe a bug).... I also tested it in Qt4.8.4 (msvc2008) and it works. Never tried on mingw and msvc2010 though.

          Please visit my open-source projects at https://github.com/Code-ReaQtor.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cincirin
            wrote on last edited by
            #5

            [quote author="Code_ReaQtor" date="1355405419"]mingw and msvc2010 outputs error, IDK why? maybe a bug).... .[/quote]

            What error do you have ? On my end it works perfectly with mingw up to 4.7.4 and with VC2010

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

              [quote author="cincirin" date="1355405869"]
              What error do you have ? On my end it works perfectly with mingw up to 4.7.4 and with VC2010
              [/quote]

              I actually got the error on Qt 4.8.3 ONLY (mingw and msvc2010)

              It says something like "COFF: file invalid or corrupt"

              At first, I thought the problem was with the .ico file that I used but I compiled it with another version and it worked.

              To summarize:
              It didn't worked on Qt4.8.3 mingw and msvc2010
              It worked with Qt4.8.3 msvc2008 and other versions not mentioned above (Qt4.8.4 mingw and msvc2010 not tested)

              Please visit my open-source projects at https://github.com/Code-ReaQtor.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                cincirin
                wrote on last edited by
                #7

                ok, I didn't tested with 4.8.3 :-), but with 4.8.4 it work with vc2010 (and maybe with mingw)

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on last edited by
                  #8

                  The COFF file error is triggered by a bug in the compiler. I documented how I managed to get the fix installed here: https://qt-project.org/wiki/Category:Tools::msvc

                  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