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. add EXE Icon
Forum Updated to NodeBB v4.3 + New Features

add EXE Icon

Scheduled Pinned Locked Moved Solved General and Desktop
iconexeexecutable
9 Posts 3 Posters 1.1k 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.
  • J Offline
    J Offline
    Joe von Habsburg
    wrote on 1 Apr 2024, 21:50 last edited by
    #1

    I want to add exe icon with cmake. I use qtcreator and I can give icon to mainwindow but I want to set to exe. How could I do it?

    P 1 Reply Last reply 1 Apr 2024, 22:08
    0
    • J Joe von Habsburg
      1 Apr 2024, 21:50

      I want to add exe icon with cmake. I use qtcreator and I can give icon to mainwindow but I want to set to exe. How could I do it?

      P Offline
      P Offline
      Pl45m4
      wrote on 1 Apr 2024, 22:08 last edited by
      #2

      @Joe-von-Habsburg

      This is platform-dependent and is described here:

      • https://doc.qt.io/qt-6/appicon.html

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      J 1 Reply Last reply 1 Apr 2024, 22:12
      2
      • P Pl45m4
        1 Apr 2024, 22:08

        @Joe-von-Habsburg

        This is platform-dependent and is described here:

        • https://doc.qt.io/qt-6/appicon.html
        J Offline
        J Offline
        Joe von Habsburg
        wrote on 1 Apr 2024, 22:12 last edited by Joe von Habsburg 4 Jan 2024, 22:16
        #3

        @Pl45m4 yes I read there but I do not understand.

        firstly I create rc file also I have qrc file and, I add that line the rc file.

        IDI_ICON1               ICON    "Resources/images/myappico.ico"
        

        .After rc file will be added to cmake.

          set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/qt5app.rc")
            add_executable(qt5app main.cpp ${APP_ICON_RESOURCE_WINDOWS})
        

        (That step create new layer on project)

        It is very complex and not understanable. Is my step right ?

        P B 2 Replies Last reply 1 Apr 2024, 22:16
        0
        • J Joe von Habsburg
          1 Apr 2024, 22:12

          @Pl45m4 yes I read there but I do not understand.

          firstly I create rc file also I have qrc file and, I add that line the rc file.

          IDI_ICON1               ICON    "Resources/images/myappico.ico"
          

          .After rc file will be added to cmake.

            set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/qt5app.rc")
              add_executable(qt5app main.cpp ${APP_ICON_RESOURCE_WINDOWS})
          

          (That step create new layer on project)

          It is very complex and not understanable. Is my step right ?

          P Offline
          P Offline
          Pl45m4
          wrote on 1 Apr 2024, 22:16 last edited by Pl45m4 4 Jan 2024, 22:24
          #4

          @Joe-von-Habsburg said in add EXE Icon:

          IDI_ICON1 ICON "Resources/images/myappico.ico"

          This is from the guide's qmake section
          [Edit: but it's an overall resource example actually]

          This:

              set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/resources/photosurface.rc")
              qt_add_executable(photosurfaceexample main.cpp ${app_icon_resource_windows})
          

          and a resource file which contains your icon should work with cmake.

          How you create the resource file is also linked and explained here:

          • https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files

          Just read that you only use QtCreator and not Visual Studio.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          J 1 Reply Last reply 1 Apr 2024, 22:27
          1
          • P Pl45m4
            1 Apr 2024, 22:16

            @Joe-von-Habsburg said in add EXE Icon:

            IDI_ICON1 ICON "Resources/images/myappico.ico"

            This is from the guide's qmake section
            [Edit: but it's an overall resource example actually]

            This:

                set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/resources/photosurface.rc")
                qt_add_executable(photosurfaceexample main.cpp ${app_icon_resource_windows})
            

            and a resource file which contains your icon should work with cmake.

            How you create the resource file is also linked and explained here:

            • https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files

            Just read that you only use QtCreator and not Visual Studio.

            J Offline
            J Offline
            Joe von Habsburg
            wrote on 1 Apr 2024, 22:27 last edited by
            #5

            @Pl45m4 said in add EXE Icon:

            photosurface.rc

            what is that mean ? I realy do not know. I have .ico file. and how can I convert my ico file to rc file.

            @Pl45m4 said in add EXE Icon:

            How you create the resource file is also linked and explained here:

            https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files

            thank you, I will check

            P 1 Reply Last reply 1 Apr 2024, 22:40
            0
            • J Joe von Habsburg
              1 Apr 2024, 22:27

              @Pl45m4 said in add EXE Icon:

              photosurface.rc

              what is that mean ? I realy do not know. I have .ico file. and how can I convert my ico file to rc file.

              @Pl45m4 said in add EXE Icon:

              How you create the resource file is also linked and explained here:

              https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files

              thank you, I will check

              P Offline
              P Offline
              Pl45m4
              wrote on 1 Apr 2024, 22:40 last edited by Pl45m4 4 Jan 2024, 22:42
              #6

              @Joe-von-Habsburg said in add EXE Icon:

              what is that mean ? I realy do not know. I have .ico file. and how can I convert my ico file to rc file.

              This was the example from here:

              • https://doc.qt.io/qt-6/appicon.html#using-cmake-on-windows

              The Microsoft link is only relevant, when you use Visual Studio to create your resource file.

              Even this is in the qmake section, I think it will work for you as .rc file

              IDI_ICON1     ICON    "path/to/myappico.ico"
              

              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              J 1 Reply Last reply 1 Apr 2024, 22:48
              1
              • P Pl45m4
                1 Apr 2024, 22:40

                @Joe-von-Habsburg said in add EXE Icon:

                what is that mean ? I realy do not know. I have .ico file. and how can I convert my ico file to rc file.

                This was the example from here:

                • https://doc.qt.io/qt-6/appicon.html#using-cmake-on-windows

                The Microsoft link is only relevant, when you use Visual Studio to create your resource file.

                Even this is in the qmake section, I think it will work for you as .rc file

                IDI_ICON1     ICON    "path/to/myappico.ico"
                
                J Offline
                J Offline
                Joe von Habsburg
                wrote on 1 Apr 2024, 22:48 last edited by
                #7

                @Pl45m4 could you give code example or command example ? I could not :(

                1 Reply Last reply
                0
                • J Joe von Habsburg
                  1 Apr 2024, 22:12

                  @Pl45m4 yes I read there but I do not understand.

                  firstly I create rc file also I have qrc file and, I add that line the rc file.

                  IDI_ICON1               ICON    "Resources/images/myappico.ico"
                  

                  .After rc file will be added to cmake.

                    set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/qt5app.rc")
                      add_executable(qt5app main.cpp ${APP_ICON_RESOURCE_WINDOWS})
                  

                  (That step create new layer on project)

                  It is very complex and not understanable. Is my step right ?

                  B Offline
                  B Offline
                  Bonnie
                  wrote on 2 Apr 2024, 01:47 last edited by Bonnie 4 Feb 2024, 01:49
                  #8

                  @Joe-von-Habsburg said in add EXE Icon:

                  firstly I create rc file also I have qrc file and, I add that line the rc file.

                  IDI_ICON1               ICON    "Resources/images/myappico.ico"
                  

                  .After rc file will be added to cmake.

                    set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/qt5app.rc")
                      add_executable(qt5app main.cpp ${APP_ICON_RESOURCE_WINDOWS})
                  

                  This is actually right. Did you not make it?
                  Not quite understand your qrc part though, rc file and qrc file are totally irrelevant.

                  J 1 Reply Last reply 3 Apr 2024, 06:56
                  2
                  • B Bonnie
                    2 Apr 2024, 01:47

                    @Joe-von-Habsburg said in add EXE Icon:

                    firstly I create rc file also I have qrc file and, I add that line the rc file.

                    IDI_ICON1               ICON    "Resources/images/myappico.ico"
                    

                    .After rc file will be added to cmake.

                      set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/qt5app.rc")
                        add_executable(qt5app main.cpp ${APP_ICON_RESOURCE_WINDOWS})
                    

                    This is actually right. Did you not make it?
                    Not quite understand your qrc part though, rc file and qrc file are totally irrelevant.

                    J Offline
                    J Offline
                    Joe von Habsburg
                    wrote on 3 Apr 2024, 06:56 last edited by Joe von Habsburg 4 Mar 2024, 07:06
                    #9

                    @Bonnie said in add EXE Icon:

                    Did you not make it?
                    Yes I did now :)

                    Thank you so much for your helping

                    IDI_ICON1               ICON    "Resources/images/myapp.ico"
                    

                    .rc file has been created by notepad

                    set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/icon.rc")
                    
                    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                        qt_add_executable(MyApp
                            MANUAL_FINALIZATION
                            ${PROJECT_SOURCES}
                            ${QM_FILES}
                            ${APP_ICON_RESOURCE_WINDOWS}
                            ...
                            icon.rc
                    
                        )
                    
                    
                    1 Reply Last reply
                    0
                    • J Joe von Habsburg has marked this topic as solved on 3 Apr 2024, 07:05

                    1/9

                    1 Apr 2024, 21:50

                    • Login

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