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. Have to put an icon on file extensions of a program on Windows explorer
Forum Updated to NodeBB v4.3 + New Features

Have to put an icon on file extensions of a program on Windows explorer

Scheduled Pinned Locked Moved Unsolved General and Desktop
34 Posts 6 Posters 9.7k Views 4 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.
  • tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by
    #1

    Hi all,

    Here is the program from the book "C++-GUI-Programming-with-Qt-4-2nd Edition".

    I want to modify the code so that when that program is being used on any Windows machine it puts an icon on its stored files on Windows Explorer.

    I sought the Web and was told that I should change the code of both the script file and also the program.

    Here is the script file's content:

    function Component()
    {
        // default constructor
    }
    
    Component.prototype.createOperations = function()
    {
        // call the base create operations function
         component.createOperations();
          if (installer.value("os") == "win")
            {
               var userProfile = installer.environmentVariable("USERPROFILE");
               installer.setValue("UserProfile", userProfile);
    
               component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
               "@UserProfile@/Desktop/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@",
               "iconPath=@TargetDir@/Spreadsheet.ico");
    
               component.addOperation("CreateShortcut", "@TargetDir@/QSpreadsheet.exe",
               "@TargetDir@/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
    
               component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
               "@StartMenuDir@/Spreadsheet.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
    
               component.addOperation("RegisterFileType", "sp",
               "@TargetDir@\\Spreadsheet.exe \" %1\"", "Tomy Inc",
               "application/x-binary", "@TargetDir@/Spreadsheet.ico",
               "ProgId=Spreadsheet.sp");
            }
     }
    

    And use QSettings.

    void MainWindow::readSettings()
    {
        QSettings settings("Tomy Inc.", "Spreadsheet");
        restoreGeometry(settings.value("geometry").toByteArray());
        recentFiles = settings.value("recentFiles").toStringList();
        updateRecentFileActions();
        bool showGrid = settings.value("showGrid", true).toBool();
        showGridAction->setChecked(showGrid);
        bool autoRecalc = settings.value("autoRecalc", true).toBool();
        autoRecalcAction->setChecked(autoRecalc);
    
        QSettings s("HKEY_CURRENT_USER\\SOFTWARE\\CLASSES",
                    QSettings::NativeFormat);
        s.setValue(".sp/DefaultIcon/.", QDir::toNativeSeparators
                   (qApp->applicationFilePath()));
        s.setValue(".sp/.","Tomy Inc.Spreadsheet.v1");
        s.setValue("Tomy Inc.Spreadsheet.v1/shell/open/command/.",
         QDir::toNativeSeparators(qApp->applicationFilePath()) + " %1");
    }
    
    //*************************************************************
    
    void MainWindow::writeSettings()
    {
        QSettings settings("Tomy Inc.", "Spreadsheet");
        settings.setValue("geometry", saveGeometry());
        settings.setValue("recentFiles", recentFiles);
        settings.setValue("showGrid", showGridAction->isChecked());
        settings.setValue("autoRecalc", autoRecalcAction->isChecked());
    
        QSettings s("HKEY_CURRENT_USER\\SOFTWARE\\CLASSES",
                    QSettings::NativeFormat);
        s.setValue(".sp/DefaultIcon/.", QDir::toNativeSeparators
                   (qApp->applicationFilePath()));
        s.setValue(".sp/.","Tomy Inc.Spreadsheet.v1");
        s.setValue("Tomy Inc.Spreadsheet.v1/shell/open/command/.",
         QDir::toNativeSeparators(qApp->applicationFilePath()) + " %1");
    }
    

    There is/are obviously some error(s). When I install the program on Windows no icons will be stored on the files I save on Windows Explorer.

    PS: I do not want to modify my registery to do the job; I want to have the program do that on "any" windows machine it will be installed on.

    One question here: How do you create applications?

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • tomyT tomy

      Hi all,

      Here is the program from the book "C++-GUI-Programming-with-Qt-4-2nd Edition".

      I want to modify the code so that when that program is being used on any Windows machine it puts an icon on its stored files on Windows Explorer.

      I sought the Web and was told that I should change the code of both the script file and also the program.

      Here is the script file's content:

      function Component()
      {
          // default constructor
      }
      
      Component.prototype.createOperations = function()
      {
          // call the base create operations function
           component.createOperations();
            if (installer.value("os") == "win")
              {
                 var userProfile = installer.environmentVariable("USERPROFILE");
                 installer.setValue("UserProfile", userProfile);
      
                 component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
                 "@UserProfile@/Desktop/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@",
                 "iconPath=@TargetDir@/Spreadsheet.ico");
      
                 component.addOperation("CreateShortcut", "@TargetDir@/QSpreadsheet.exe",
                 "@TargetDir@/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
      
                 component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
                 "@StartMenuDir@/Spreadsheet.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
      
                 component.addOperation("RegisterFileType", "sp",
                 "@TargetDir@\\Spreadsheet.exe \" %1\"", "Tomy Inc",
                 "application/x-binary", "@TargetDir@/Spreadsheet.ico",
                 "ProgId=Spreadsheet.sp");
              }
       }
      

      And use QSettings.

      void MainWindow::readSettings()
      {
          QSettings settings("Tomy Inc.", "Spreadsheet");
          restoreGeometry(settings.value("geometry").toByteArray());
          recentFiles = settings.value("recentFiles").toStringList();
          updateRecentFileActions();
          bool showGrid = settings.value("showGrid", true).toBool();
          showGridAction->setChecked(showGrid);
          bool autoRecalc = settings.value("autoRecalc", true).toBool();
          autoRecalcAction->setChecked(autoRecalc);
      
          QSettings s("HKEY_CURRENT_USER\\SOFTWARE\\CLASSES",
                      QSettings::NativeFormat);
          s.setValue(".sp/DefaultIcon/.", QDir::toNativeSeparators
                     (qApp->applicationFilePath()));
          s.setValue(".sp/.","Tomy Inc.Spreadsheet.v1");
          s.setValue("Tomy Inc.Spreadsheet.v1/shell/open/command/.",
           QDir::toNativeSeparators(qApp->applicationFilePath()) + " %1");
      }
      
      //*************************************************************
      
      void MainWindow::writeSettings()
      {
          QSettings settings("Tomy Inc.", "Spreadsheet");
          settings.setValue("geometry", saveGeometry());
          settings.setValue("recentFiles", recentFiles);
          settings.setValue("showGrid", showGridAction->isChecked());
          settings.setValue("autoRecalc", autoRecalcAction->isChecked());
      
          QSettings s("HKEY_CURRENT_USER\\SOFTWARE\\CLASSES",
                      QSettings::NativeFormat);
          s.setValue(".sp/DefaultIcon/.", QDir::toNativeSeparators
                     (qApp->applicationFilePath()));
          s.setValue(".sp/.","Tomy Inc.Spreadsheet.v1");
          s.setValue("Tomy Inc.Spreadsheet.v1/shell/open/command/.",
           QDir::toNativeSeparators(qApp->applicationFilePath()) + " %1");
      }
      

      There is/are obviously some error(s). When I install the program on Windows no icons will be stored on the files I save on Windows Explorer.

      PS: I do not want to modify my registery to do the job; I want to have the program do that on "any" windows machine it will be installed on.

      One question here: How do you create applications?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @tomy said in Have to put an icon on file extensions of a program on Windows explorer:

      I do not want to modify my registery to do the job

      But then how do you want to achieve this? Registry is the way to do this on Windows.

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

      tomyT 1 Reply Last reply
      1
      • jsulmJ jsulm

        @tomy said in Have to put an icon on file extensions of a program on Windows explorer:

        I do not want to modify my registery to do the job

        But then how do you want to achieve this? Registry is the way to do this on Windows.

        tomyT Offline
        tomyT Offline
        tomy
        wrote on last edited by
        #3

        @jsulm

        But then how do you want to achieve this? Registry is the way to do this on Windows.

        I meant I don't want to manipulate the registery directly; I want to manipulate the registery "inside the code" so that the code/program itself manipulates the registery in every Windows machine it will be installing on.

        For example you install a word processing application on Windows. You run the app and create a new file, put some data into it, and finally save it under the name "myfile_1" on Desktop. Doesn't that file have an icon on itself? It always has. Because the developer of that application has written the code so that it makes the Windows put some nice icon on the files that will be stored on Windows Explorer. I need this.
        Could I convey the issue correctly?

        jsulmJ 2 Replies Last reply
        0
        • tomyT tomy

          @jsulm

          But then how do you want to achieve this? Registry is the way to do this on Windows.

          I meant I don't want to manipulate the registery directly; I want to manipulate the registery "inside the code" so that the code/program itself manipulates the registery in every Windows machine it will be installing on.

          For example you install a word processing application on Windows. You run the app and create a new file, put some data into it, and finally save it under the name "myfile_1" on Desktop. Doesn't that file have an icon on itself? It always has. Because the developer of that application has written the code so that it makes the Windows put some nice icon on the files that will be stored on Windows Explorer. I need this.
          Could I convey the issue correctly?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @tomy Then I don't understand the problem: you already have the code, right? Just execute it when your app is starting. Additionaly you could first check whether you already did this before if not then execute that code.

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

          tomyT 1 Reply Last reply
          1
          • tomyT tomy

            @jsulm

            But then how do you want to achieve this? Registry is the way to do this on Windows.

            I meant I don't want to manipulate the registery directly; I want to manipulate the registery "inside the code" so that the code/program itself manipulates the registery in every Windows machine it will be installing on.

            For example you install a word processing application on Windows. You run the app and create a new file, put some data into it, and finally save it under the name "myfile_1" on Desktop. Doesn't that file have an icon on itself? It always has. Because the developer of that application has written the code so that it makes the Windows put some nice icon on the files that will be stored on Windows Explorer. I need this.
            Could I convey the issue correctly?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @tomy In this thread https://forum.qt.io/topic/82560/my-app-s-stored-files-shape-are-as-unknown-files/12 there is already this link: https://msdn.microsoft.com/de-de/library/windows/desktop/ee872121(v=vs.85).aspx

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

            1 Reply Last reply
            1
            • jsulmJ jsulm

              @tomy Then I don't understand the problem: you already have the code, right? Just execute it when your app is starting. Additionaly you could first check whether you already did this before if not then execute that code.

              tomyT Offline
              tomyT Offline
              tomy
              wrote on last edited by
              #6

              @jsulm

              Then I don't understand the problem: you already have the code, right?

              Right.

              Just execute it when your app is starting. Additionaly you could first check whether you already did this before if not then execute that code.

              It's now me that doesn't understand!

              Please listen again, I want some nice icon to be put on the files I save.

              0_1505723830163_Capture.PNG

              Here is a file of MS Excel, and one of MS Word. As they are shown they have nice icon/shape/design on themselves but four files of the app we are talking about have no icon/shape/design on themselves, as if they are not known by Windows.

              jsulmJ T 2 Replies Last reply
              0
              • tomyT tomy

                @jsulm

                Then I don't understand the problem: you already have the code, right?

                Right.

                Just execute it when your app is starting. Additionaly you could first check whether you already did this before if not then execute that code.

                It's now me that doesn't understand!

                Please listen again, I want some nice icon to be put on the files I save.

                0_1505723830163_Capture.PNG

                Here is a file of MS Excel, and one of MS Word. As they are shown they have nice icon/shape/design on themselves but four files of the app we are talking about have no icon/shape/design on themselves, as if they are not known by Windows.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @tomy I know what you want to do. On windows this is done via registry, so out of scope of Qt. You need to find out what exactly you need to change in Windows registry. See MSDN.
                The icon is associated with a file type/extension.

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

                1 Reply Last reply
                1
                • tomyT tomy

                  @jsulm

                  Then I don't understand the problem: you already have the code, right?

                  Right.

                  Just execute it when your app is starting. Additionaly you could first check whether you already did this before if not then execute that code.

                  It's now me that doesn't understand!

                  Please listen again, I want some nice icon to be put on the files I save.

                  0_1505723830163_Capture.PNG

                  Here is a file of MS Excel, and one of MS Word. As they are shown they have nice icon/shape/design on themselves but four files of the app we are talking about have no icon/shape/design on themselves, as if they are not known by Windows.

                  T Offline
                  T Offline
                  Tikani
                  wrote on last edited by Tikani
                  #8

                  @tomy
                  Windows registers icons for file types only by extensions, it doesn't check byte sequences in files' headers like Linux.
                  Thus, use WinAPI to edit registry from code on the installation stage of your program. Embed this functionality directly to the application - it's a bad practise. Only an installator must take responsibility for application's integration with a system.

                  1 Reply Last reply
                  2
                  • Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    I recently answered similar question: How to set icon for a custom type of file using Qt.

                    As @Tikani mentioned this should probably be done in the installation stage, i.e. in some code invoked by the installer if it doesn't provide that functionality out of the box. Assuming, of course, that you have an installer in the first place.

                    tomyT 2 Replies Last reply
                    3
                    • tomyT tomy

                      Hi all,

                      Here is the program from the book "C++-GUI-Programming-with-Qt-4-2nd Edition".

                      I want to modify the code so that when that program is being used on any Windows machine it puts an icon on its stored files on Windows Explorer.

                      I sought the Web and was told that I should change the code of both the script file and also the program.

                      Here is the script file's content:

                      function Component()
                      {
                          // default constructor
                      }
                      
                      Component.prototype.createOperations = function()
                      {
                          // call the base create operations function
                           component.createOperations();
                            if (installer.value("os") == "win")
                              {
                                 var userProfile = installer.environmentVariable("USERPROFILE");
                                 installer.setValue("UserProfile", userProfile);
                      
                                 component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
                                 "@UserProfile@/Desktop/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@",
                                 "iconPath=@TargetDir@/Spreadsheet.ico");
                      
                                 component.addOperation("CreateShortcut", "@TargetDir@/QSpreadsheet.exe",
                                 "@TargetDir@/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
                      
                                 component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
                                 "@StartMenuDir@/Spreadsheet.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
                      
                                 component.addOperation("RegisterFileType", "sp",
                                 "@TargetDir@\\Spreadsheet.exe \" %1\"", "Tomy Inc",
                                 "application/x-binary", "@TargetDir@/Spreadsheet.ico",
                                 "ProgId=Spreadsheet.sp");
                              }
                       }
                      

                      And use QSettings.

                      void MainWindow::readSettings()
                      {
                          QSettings settings("Tomy Inc.", "Spreadsheet");
                          restoreGeometry(settings.value("geometry").toByteArray());
                          recentFiles = settings.value("recentFiles").toStringList();
                          updateRecentFileActions();
                          bool showGrid = settings.value("showGrid", true).toBool();
                          showGridAction->setChecked(showGrid);
                          bool autoRecalc = settings.value("autoRecalc", true).toBool();
                          autoRecalcAction->setChecked(autoRecalc);
                      
                          QSettings s("HKEY_CURRENT_USER\\SOFTWARE\\CLASSES",
                                      QSettings::NativeFormat);
                          s.setValue(".sp/DefaultIcon/.", QDir::toNativeSeparators
                                     (qApp->applicationFilePath()));
                          s.setValue(".sp/.","Tomy Inc.Spreadsheet.v1");
                          s.setValue("Tomy Inc.Spreadsheet.v1/shell/open/command/.",
                           QDir::toNativeSeparators(qApp->applicationFilePath()) + " %1");
                      }
                      
                      //*************************************************************
                      
                      void MainWindow::writeSettings()
                      {
                          QSettings settings("Tomy Inc.", "Spreadsheet");
                          settings.setValue("geometry", saveGeometry());
                          settings.setValue("recentFiles", recentFiles);
                          settings.setValue("showGrid", showGridAction->isChecked());
                          settings.setValue("autoRecalc", autoRecalcAction->isChecked());
                      
                          QSettings s("HKEY_CURRENT_USER\\SOFTWARE\\CLASSES",
                                      QSettings::NativeFormat);
                          s.setValue(".sp/DefaultIcon/.", QDir::toNativeSeparators
                                     (qApp->applicationFilePath()));
                          s.setValue(".sp/.","Tomy Inc.Spreadsheet.v1");
                          s.setValue("Tomy Inc.Spreadsheet.v1/shell/open/command/.",
                           QDir::toNativeSeparators(qApp->applicationFilePath()) + " %1");
                      }
                      

                      There is/are obviously some error(s). When I install the program on Windows no icons will be stored on the files I save on Windows Explorer.

                      PS: I do not want to modify my registery to do the job; I want to have the program do that on "any" windows machine it will be installed on.

                      One question here: How do you create applications?

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #10

                      @tomy from those Code-Example I'm guessing you're using the QtInstallerFramework to install your App on the window PC.

                      In that case here in the official example from the docu on how to register fule extensions with Windows :-)


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      tomyT 1 Reply Last reply
                      2
                      • Chris KawaC Chris Kawa

                        I recently answered similar question: How to set icon for a custom type of file using Qt.

                        As @Tikani mentioned this should probably be done in the installation stage, i.e. in some code invoked by the installer if it doesn't provide that functionality out of the box. Assuming, of course, that you have an installer in the first place.

                        tomyT Offline
                        tomyT Offline
                        tomy
                        wrote on last edited by tomy
                        #11

                        @Chris-Kawa

                        I recently answered similar question: How to set icon for a custom type of file using Qt.

                        Glad to hear that. I will go for reading it precisely.

                        As @Tikani mentioned this should probably be done in the installation stage

                        Yes, exactly.

                        , i.e. in some code invoked by the installer if it doesn't provide that functionality out of the box. Assuming, of course, that you have an installer in the first place.

                        I use the Qt Installer Framework 2.1 (QtIFW2.0.1) for making an installer.

                        1 Reply Last reply
                        0
                        • J.HilkJ J.Hilk

                          @tomy from those Code-Example I'm guessing you're using the QtInstallerFramework to install your App on the window PC.

                          In that case here in the official example from the docu on how to register fule extensions with Windows :-)

                          tomyT Offline
                          tomyT Offline
                          tomy
                          wrote on last edited by
                          #12
                          This post is deleted!
                          1 Reply Last reply
                          0
                          • Chris KawaC Chris Kawa

                            I recently answered similar question: How to set icon for a custom type of file using Qt.

                            As @Tikani mentioned this should probably be done in the installation stage, i.e. in some code invoked by the installer if it doesn't provide that functionality out of the box. Assuming, of course, that you have an installer in the first place.

                            tomyT Offline
                            tomyT Offline
                            tomy
                            wrote on last edited by
                            #13

                            @Chris-Kawa
                            I included "shlobj.h" and used QSettings as below in the two functions where QSettings was previously used (because I was not sure where to use your code in):

                            void MainWindow::readSettings()
                            {
                                QSettings settings("Tomy Inc.", "Spreadsheet");
                                restoreGeometry(settings.value("geometry").toByteArray());
                                recentFiles = settings.value("recentFiles").toStringList();
                                updateRecentFileActions();
                                bool showGrid = settings.value("showGrid", true).toBool();
                                showGridAction->setChecked(showGrid);
                                bool autoRecalc = settings.value("autoRecalc", true).toBool();
                                autoRecalcAction->setChecked(autoRecalc);
                            
                                QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\DefaultIcon",
                                              QSettings::NativeFormat);
                                reg.setValue("Default", "C:\\Users\\Tomy\\Desktop\\package_directory"
                                             "\\packages\\com.vendor.product\\data\\Spreadsheet.ico");
                            
                                SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
                            }
                            
                            //*************************************************************
                            
                            void MainWindow::writeSettings()
                            {
                                QSettings settings("Tomy Inc.", "Spreadsheet");
                                settings.setValue("geometry", saveGeometry());
                                settings.setValue("recentFiles", recentFiles);
                                settings.setValue("showGrid", showGridAction->isChecked());
                                settings.setValue("autoRecalc", autoRecalcAction->isChecked());
                            
                               QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\DefaultIcon",
                                             QSettings::NativeFormat);
                               reg.setValue("Default", "C:\\Users\\Tomy\\Desktop\\package_directory"
                                           "\\packages\\com.vendor.product\\data\\Spreadsheet.ico");
                            
                               SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
                            }
                            

                            Then changed the installscript.qs file to its previous status:

                            function Component()
                            {
                                // default constructor
                            }
                            
                            Component.prototype.createOperations = function()
                            {
                                // call the base create operations function
                                 component.createOperations();
                                  if (installer.value("os") == "win")
                                    {
                                       var userProfile = installer.environmentVariable("USERPROFILE");
                                       installer.setValue("UserProfile", userProfile);
                            
                                       component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
                                       "@UserProfile@/Desktop/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@",
                                       "iconPath=@TargetDir@/Spreadsheet.ico");
                            
                                       component.addOperation("CreateShortcut", "@TargetDir@/QSpreadsheet.exe",
                                       "@TargetDir@/Spreadsheet.lnk" ,"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
                            
                                       component.addOperation("CreateShortcut", "@TargetDir@/Spreadsheet.exe",
                                       "@StartMenuDir@/Spreadsheet.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/Spreadsheet.ico");
                                    }
                             }
                            

                            Then created an installer and installed it on Windows. But unfortunately no icon was set!!

                            Should I add this code to the script file too?

                            1 Reply Last reply
                            0
                            • tomyT Offline
                              tomyT Offline
                              tomy
                              wrote on last edited by
                              #14

                              No any further help?? :(

                              mrjjM 1 Reply Last reply
                              0
                              • tomyT tomy

                                No any further help?? :(

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @tomy
                                Hi
                                you need to have more patience
                                Mr Chris-Kawa is not online that often.

                                1 Reply Last reply
                                1
                                • tomyT Offline
                                  tomyT Offline
                                  tomy
                                  wrote on last edited by
                                  #16

                                  I this time removed the code:

                                  QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\DefaultIcon",
                                                    QSettings::NativeFormat);
                                      reg.setValue("Default", "C:\\Users\\Tomy\\Desktop\\Spreadsheet.ico");
                                  
                                      SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
                                  

                                  from both void MainWindow::readSettings() and void MainWindow::writeSettings() functions and added it to the MainWindow's constructor body, then re-did the rest and installed that new on my Windows.
                                  Again, no changes in result!!
                                  There might be a problem either in the code or the script file.

                                  1 Reply Last reply
                                  0
                                  • tomyT Offline
                                    tomyT Offline
                                    tomy
                                    wrote on last edited by tomy
                                    #17

                                    I also tried to use this script file instead of the prior one. Created an installer using Qt Installer Framework but when installing the program faced en error.

                                    0_1505844874777_1.PNG

                                    I don't know what the right way is to do the job. Is it using that code? Or the script file? Or both of them? And what is the correct method having instructions to make the task done?

                                    jsulmJ 1 Reply Last reply
                                    0
                                    • tomyT tomy

                                      I also tried to use this script file instead of the prior one. Created an installer using Qt Installer Framework but when installing the program faced en error.

                                      0_1505844874777_1.PNG

                                      I don't know what the right way is to do the job. Is it using that code? Or the script file? Or both of them? And what is the correct method having instructions to make the task done?

                                      jsulmJ Offline
                                      jsulmJ Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      @tomy Correct way would be to search on MSDN as this is Windows only thing and not really related to Qt.

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

                                      tomyT 1 Reply Last reply
                                      0
                                      • jsulmJ jsulm

                                        @tomy Correct way would be to search on MSDN as this is Windows only thing and not really related to Qt.

                                        tomyT Offline
                                        tomyT Offline
                                        tomy
                                        wrote on last edited by
                                        #19

                                        @jsulm
                                        I think MSDN talks about setting the icon on my Windows. So if I send the application for you, you too should set the icon on your Windows, and if we send the application for a hundred people, those a hundred plus we two should set the icon and so on.
                                        But if we set the icon using some method by the installation stage of the program, the program "itself" sets the icon for each and every user. No need to that 102 (or any number) persons set the icon themselves (apart from having good knowledge to be able to use registery that some users might not have).
                                        If you disagree please tell me your opinion.

                                        jsulmJ 1 Reply Last reply
                                        0
                                        • tomyT tomy

                                          @jsulm
                                          I think MSDN talks about setting the icon on my Windows. So if I send the application for you, you too should set the icon on your Windows, and if we send the application for a hundred people, those a hundred plus we two should set the icon and so on.
                                          But if we set the icon using some method by the installation stage of the program, the program "itself" sets the icon for each and every user. No need to that 102 (or any number) persons set the icon themselves (apart from having good knowledge to be able to use registery that some users might not have).
                                          If you disagree please tell me your opinion.

                                          jsulmJ Offline
                                          jsulmJ Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          @tomy Wrong. Why do you think so?
                                          You need to use win32 API to achieve what you want in your app, so your app can set the icon by itself (and not the user!) or the installer.
                                          win32 API is not Qt that's why I suggest to look at MSDN to find out how ann app or installer can do this.
                                          MSDN is for developers not users by the way.

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

                                          tomyT 1 Reply Last reply
                                          1

                                          • Login

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