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. How to assign an icon to a file type of a Qt program using the installscript file

How to assign an icon to a file type of a Qt program using the installscript file

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 6.0k 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.
  • J Offline
    J Offline
    JonB
    wrote on 23 Sept 2017, 10:50 last edited by JonB
    #9

    I am assuming your statement "But when I make the installer this way, no icon will be set on the file type of the program." you mean that you are not seeing the right icon on a .sp file, not the icons on the 3 shortcuts to your .exe ... right?

    If I were trying to solve this, I would go:

    • Google for "windows set file types icon". You'll have to read something like https://superuser.com/questions/301226/manually-change-filetype-icons-in-windows-7 or https://www.howtogeek.com/howto/12383/change-a-file-types-icon-in-windows-7/ or there's even a video at https://www.youtube.com/watch?v=tEer0_LjRQY. Looks like you'll either need to download a bit of freeware to do it nicely, or read up on how to do it directly in the Registry.
    • Get your .sp associated with your .exe and get its icon assigned to whatever you want.
    • Search registry for mentions of your .ico file and see what it put where.

    For all I know, it might not be possible to associate a .ico file with a file type. Usually the way this is done is to embed the icon inside your .exe and set the icon by pointing into the .exe correctly. (That is what the example http://doc.qt.io/qtinstallerframework/qt-installer-framework-registerfileextension-example.html I mentioned does; I don't actually see other examples where an external .ico file is used. Actually see https://msdn.microsoft.com/en-us/library/windows/desktop/hh127427(v=vs.85).aspx too, which implies it should work for a .ico.) Like I said, I have never actually done this, I'm just pointing the way for you....

    T 1 Reply Last reply 23 Sept 2017, 11:04
    0
    • J JonB
      23 Sept 2017, 10:50

      I am assuming your statement "But when I make the installer this way, no icon will be set on the file type of the program." you mean that you are not seeing the right icon on a .sp file, not the icons on the 3 shortcuts to your .exe ... right?

      If I were trying to solve this, I would go:

      • Google for "windows set file types icon". You'll have to read something like https://superuser.com/questions/301226/manually-change-filetype-icons-in-windows-7 or https://www.howtogeek.com/howto/12383/change-a-file-types-icon-in-windows-7/ or there's even a video at https://www.youtube.com/watch?v=tEer0_LjRQY. Looks like you'll either need to download a bit of freeware to do it nicely, or read up on how to do it directly in the Registry.
      • Get your .sp associated with your .exe and get its icon assigned to whatever you want.
      • Search registry for mentions of your .ico file and see what it put where.

      For all I know, it might not be possible to associate a .ico file with a file type. Usually the way this is done is to embed the icon inside your .exe and set the icon by pointing into the .exe correctly. (That is what the example http://doc.qt.io/qtinstallerframework/qt-installer-framework-registerfileextension-example.html I mentioned does; I don't actually see other examples where an external .ico file is used. Actually see https://msdn.microsoft.com/en-us/library/windows/desktop/hh127427(v=vs.85).aspx too, which implies it should work for a .ico.) Like I said, I have never actually done this, I'm just pointing the way for you....

      T Offline
      T Offline
      tomy
      wrote on 23 Sept 2017, 11:04 last edited by tomy
      #10

      @JNBarchan

      I am assuming your statement "But when I make the installer this way, no icon will be set on the file type of the program." you mean that you are not seeing the right icon on a .sp file, not the icons on the 3 shortcuts to your .exe ... right?

      Yes. All three shortcuts have the icon set on themselves. By running them the program shows up.
      But on the files having the extension .sp, no icon is set.

      If I were trying to solve this, I would go:

      • Google for "windows set file types icon". You'll have to read something like https://superuser.com/questions/301226/manually-change-filetype-icons-in-windows-7. Looks like you'll either need to download a bit of freeware to do it nicely, or read up on how to do it directly in the Registry.

      Please note that I thinking about the users for whom I will send the file to install it on their Windows machine. Setting the icon should be done in the process of installation.

      For all I know, it might not be possible to associate a .ico file with a file type.

      Please look at this:

      0_1506164527092_Capture.PNG

      Those two .docx and .xlsx have icons on themselves but the .sp file has no one it itself.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JonB
        wrote on 23 Sept 2017, 11:21 last edited by JonB
        #11

        I am not suggesting that your end users will have to Google for or do the file type icon association themselves! I'm suggesting you need to do so, as a "test run", in order to know what you need/does/does not work from the Qt Installer!

        I do understand the screenshot you are showing. You could either search the Registry to see how that is done for .xslx file types (btw, I think you'll find the icons are embedded in the WORD.EXE application not an external .ico file, though that may not be relevant), or you could follow the steps I have suggested.

        At the end of the day, I suspect your problem is how to do it right under Windows, rather than anything specific to do with Qt Installer. (Though I did suggest you just try using \ instead of / in your CreateShortcut's iconPath specification, that a very quick that's might be worth a try.)

        1 Reply Last reply
        2
        • T Offline
          T Offline
          tomy
          wrote on 23 Sept 2017, 19:15 last edited by tomy
          #12

          @JNBarchan

          is that a typo?
          with forward-slash

          I read Docs and a thread and modified the script file and tried to install the app many times but no success. This is the last modification:

          component.addElevatedOperation("RegisterFileType", "sp",
                  "@TargetDir@/Spreadsheet.exe/" %1/"", "Abbasi Files", "application/Abbasi",
                  "@DesktopDir@/Spreadsheet.ico", "ProgId=Spreadsheet.sp")
          

          Play with that till it works, bring back any alterations to your Qt Installer Script?

          What do you mean?

          get it working manually from Windows and see how that compares to what the Installer produces.

          I couldn't find a clear and not-difficult way to register a file type on registery to compare it with the path and values the installer makes.
          The installer creates a value in the path below:
          0_1506192442425_Capture.PNG

          RegisterFileTypeOperation::performOperation()
          Get your .sp associated with your .exe and get its icon assigned to whatever you want.

          I couldn't understand these well.

          You could either search the Registry to see how that is done for .xslx file types

          Here is that which is much more complicated than the one for .sp:

          0_1506194011224_Capture.PNG

          (Though I did suggest you just try using \ instead of / in your CreateShortcut's iconPath specification, that a very quick that's might be worth a try.)

          I did it, and test it many times. No success until now.

          Did you test it on your system?

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tomy
            wrote on 23 Sept 2017, 20:04 last edited by tomy
            #13

            Something new happened!
            I searched for .sp in the registery and deleted all of them there.
            Then installed the program and restarted the Windows. This is the result:

            0_1506196798659_Capture.PNG

            The icon is set on both files 1 & 2.

            I ran the app using that shortcut and opened the files using the Open button. They opened. => No changes on files. Good.

            Then opened the files (1 & 2) using double clicking and chosing the application to run and "unchecked" the button:
            Always use the selected program to open this kind of file.
            Again they were opened and no changes on icons. Good.

            This time I checked that button and ran the files again. And it's the outcome: :( :(

            0_1506197068032_2.PNG

            jsulmJ 1 Reply Last reply 25 Sept 2017, 07:36
            0
            • T tomy
              23 Sept 2017, 20:04

              Something new happened!
              I searched for .sp in the registery and deleted all of them there.
              Then installed the program and restarted the Windows. This is the result:

              0_1506196798659_Capture.PNG

              The icon is set on both files 1 & 2.

              I ran the app using that shortcut and opened the files using the Open button. They opened. => No changes on files. Good.

              Then opened the files (1 & 2) using double clicking and chosing the application to run and "unchecked" the button:
              Always use the selected program to open this kind of file.
              Again they were opened and no changes on icons. Good.

              This time I checked that button and ran the files again. And it's the outcome: :( :(

              0_1506197068032_2.PNG

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on 25 Sept 2017, 07:36 last edited by
              #14

              @tomy You associated now this file type with your app. Does your app have an registered icon?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              T 1 Reply Last reply 25 Sept 2017, 07:58
              1
              • jsulmJ jsulm
                25 Sept 2017, 07:36

                @tomy You associated now this file type with your app. Does your app have an registered icon?

                T Offline
                T Offline
                tomy
                wrote on 25 Sept 2017, 07:58 last edited by
                #15

                @jsulm

                You associated now this file type with your app. Does your app have an registered icon?

                I'm not sure what you mean by registered icon, but, the shortcut above the files 1 and 2 at the screenshot above has an icon on itself and when double clicked, it runs the application. I put the icon in the folder data of the package directory folder and using it the installer registered that icon for the program I think.

                jsulmJ 1 Reply Last reply 25 Sept 2017, 07:59
                0
                • T tomy
                  25 Sept 2017, 07:58

                  @jsulm

                  You associated now this file type with your app. Does your app have an registered icon?

                  I'm not sure what you mean by registered icon, but, the shortcut above the files 1 and 2 at the screenshot above has an icon on itself and when double clicked, it runs the application. I put the icon in the folder data of the package directory folder and using it the installer registered that icon for the program I think.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 25 Sept 2017, 07:59 last edited by
                  #16

                  @tomy Is your app shown with an icon in Windows (start menu for example)?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  T 1 Reply Last reply 25 Sept 2017, 08:02
                  0
                  • jsulmJ jsulm
                    25 Sept 2017, 07:59

                    @tomy Is your app shown with an icon in Windows (start menu for example)?

                    T Offline
                    T Offline
                    tomy
                    wrote on 25 Sept 2017, 08:02 last edited by
                    #17

                    @jsulm

                    Is your app shown with an icon in Windows (start menu for example)?

                    Yes.
                    0_1506326511035_Untitled.png

                    Pranit PatilP 1 Reply Last reply 23 Jun 2018, 11:18
                    0
                    • T tomy
                      25 Sept 2017, 08:02

                      @jsulm

                      Is your app shown with an icon in Windows (start menu for example)?

                      Yes.
                      0_1506326511035_Untitled.png

                      Pranit PatilP Offline
                      Pranit PatilP Offline
                      Pranit Patil
                      wrote on 23 Jun 2018, 11:18 last edited by
                      #18

                      @tomy Can you share full process bz im facing same problem.

                      Thank You

                      @Embedded Software Developer
                      God has given you one face, and you make yourself another.

                      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