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. Save Programm Settings internally + how to organize with folders?

Save Programm Settings internally + how to organize with folders?

Scheduled Pinned Locked Moved Solved General and Desktop
qt c++foldersettings
18 Posts 6 Posters 1.1k 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 StudentScripter

    @sierdzio Thank you very much. How would i need to update the path? It looks like this right now:
    How can i for example put these files into a subfolder named "DockableItemsFolder"

    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        qt_add_executable(EditorWIPNeu
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
    		CustomDockableItemList.cpp 
                    CustomDockableItemList.h
    }
    
    sierdzioS Offline
    sierdzioS Offline
    sierdzio
    Moderators
    wrote on last edited by
    #5

    @StudentScripter said in Save Programm Settings internally + how to organize with folders?:

    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        qt_add_executable(EditorWIPNeu
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
    		DockableItemsFolder/CustomDockableItemList.cpp 
                    DockableItemsFolder/CustomDockableItemList.h
    }
    

    (Z(:^

    S 1 Reply Last reply
    0
    • sierdzioS sierdzio

      @StudentScripter said in Save Programm Settings internally + how to organize with folders?:

      if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
          qt_add_executable(EditorWIPNeu
              MANUAL_FINALIZATION
              ${PROJECT_SOURCES}
      		DockableItemsFolder/CustomDockableItemList.cpp 
                      DockableItemsFolder/CustomDockableItemList.h
      }
      
      S Offline
      S Offline
      StudentScripter
      wrote on last edited by
      #6

      @sierdzio Thank you very much and well, guess i have to use something different than headders cause the values should be modifiable and shall be saved as new standards when closing the application.

      open application --> set Standard values --> interact with application and change settings--> close Application and save new changed values as new standards

      Guess qrc is the way to go here or qsettings.

      SGaistS 1 Reply Last reply
      0
      • S StudentScripter

        @sierdzio Thank you very much and well, guess i have to use something different than headders cause the values should be modifiable and shall be saved as new standards when closing the application.

        open application --> set Standard values --> interact with application and change settings--> close Application and save new changed values as new standards

        Guess qrc is the way to go here or qsettings.

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @StudentScripter hi,

        QSettings is a good way to go. If you want to use JSON with it, you can leverage registerFormat.

        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
        2
        • S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #8

          Settings need to be changed in a separate file (or the registry on Windows). Qt does not provide a way to change the executable itself. Files inside qrc are read-only (even if they are separate files on disk, i.e. qrc files read at runtime).

          Every operating system has a default way of storing settings. Just use QSettings (with your "company" and application name) and it will store it in the right place. You can add default values for your settings with QSettings so that you can create the initial settings file.

          S 1 Reply Last reply
          0
          • S SimonSchroeder

            Settings need to be changed in a separate file (or the registry on Windows). Qt does not provide a way to change the executable itself. Files inside qrc are read-only (even if they are separate files on disk, i.e. qrc files read at runtime).

            Every operating system has a default way of storing settings. Just use QSettings (with your "company" and application name) and it will store it in the right place. You can add default values for your settings with QSettings so that you can create the initial settings file.

            S Offline
            S Offline
            StudentScripter
            wrote on last edited by
            #9

            @SimonSchroeder But doesn't create qsetting endless registry entrys while testing? How to get rid of them?

            sierdzioS 1 Reply Last reply
            0
            • S StudentScripter

              @SimonSchroeder But doesn't create qsetting endless registry entrys while testing? How to get rid of them?

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #10

              @StudentScripter you can specify custom path where the settings will be saved (to a file, not registry). Then it is easy, when you need a "clean slate" you just delete the file.

              (Z(:^

              S 1 Reply Last reply
              0
              • sierdzioS sierdzio

                @StudentScripter you can specify custom path where the settings will be saved (to a file, not registry). Then it is easy, when you need a "clean slate" you just delete the file.

                S Offline
                S Offline
                StudentScripter
                wrote on last edited by
                #11

                @sierdzio

                Something like this? And than remove this path at the end when my development is finished to save it in the users registry?

                    QString filePath = "/path/to/your/settings.ini";
                    QSettings settings(filePath, QSettings::IniFormat);
                
                
                JonBJ Pl45m4P S 3 Replies Last reply
                0
                • S StudentScripter

                  @sierdzio

                  Something like this? And than remove this path at the end when my development is finished to save it in the users registry?

                      QString filePath = "/path/to/your/settings.ini";
                      QSettings settings(filePath, QSettings::IniFormat);
                  
                  
                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #12

                  @StudentScripter Yes you can do that. Or you can just go into the Registry at "your "company" and application name " and delete that.

                  S 1 Reply Last reply
                  1
                  • S StudentScripter

                    @sierdzio

                    Something like this? And than remove this path at the end when my development is finished to save it in the users registry?

                        QString filePath = "/path/to/your/settings.ini";
                        QSettings settings(filePath, QSettings::IniFormat);
                    
                    
                    Pl45m4P Offline
                    Pl45m4P Offline
                    Pl45m4
                    wrote on last edited by Pl45m4
                    #13

                    @StudentScripter said in Save Programm Settings internally + how to organize with folders?:

                    And than remove this path at the end when my development is finished to save it in the users registry?

                    Like this, or you stick to the .ini file mode and just delete it in order to be re-created in a clean state by your program.

                    @JonB said in Save Programm Settings internally + how to organize with folders?:

                    Or you can just go into the Registry at "your "company" and application name " and delete that.

                    If only every software dev would do this... :)
                    That's why 99% of all Windows users have a bloated registry... because most programs don't delete all its entries even when you uninstall them.
                    Some leave it up to you while uninstalling to check/uncheck an option to keep or delete config. and "user data" in the registry, which is fine :)


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

                    ~E. W. Dijkstra

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @StudentScripter Yes you can do that. Or you can just go into the Registry at "your "company" and application name " and delete that.

                      S Offline
                      S Offline
                      StudentScripter
                      wrote on last edited by
                      #14

                      @JonB How i the behaviour with qSetting when i allow it to do registry entrys. I don't want the endusers registry to get bloated over time.

                      Pl45m4P JonBJ 2 Replies Last reply
                      0
                      • S StudentScripter

                        @JonB How i the behaviour with qSetting when i allow it to do registry entrys. I don't want the endusers registry to get bloated over time.

                        Pl45m4P Offline
                        Pl45m4P Offline
                        Pl45m4
                        wrote on last edited by
                        #15

                        @StudentScripter said in Save Programm Settings internally + how to organize with folders?:

                        I don't want the endusers registry to get bloated over time.

                        You know what you write to registry. Every QSetting key is stored the way you set it up.
                        Unless you write (possibly) endless arrays to registry, the amount of keys should stay the same.
                        You have your "organisation" and your group, so you know where to find your keys.
                        How you delete them completely is mentioned here:

                        • https://forum.qt.io/topic/114416/deleting-all-registry-entries-under-an-organisation

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

                        ~E. W. Dijkstra

                        1 Reply Last reply
                        1
                        • S StudentScripter

                          @JonB How i the behaviour with qSetting when i allow it to do registry entrys. I don't want the endusers registry to get bloated over time.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #16

                          @StudentScripter said in Save Programm Settings internally + how to organize with folders?:

                          @JonB How i the behaviour with qSetting when i allow it to do registry entrys. I don't want the endusers registry to get bloated over time.

                          I don't understand the question. But what I can say is: when you go to production/have end users under Windows they will expect you store settings in the Registry rather than .ini files (which you won't much know where to put anyway). So it's all very well for you to decide that in your development environment you (seem to) want to use .ini file so you can delete it, but I don;t think you should do that in production/release and that means you will have different paths of code.

                          QSettings is only saving downward from one registry key (as mentioned earlier) so it's not too "polluting", and you are using the same company/application name the whole time so that's it. As for "bloated", the registry will likely be GB rather than MB big, so a few entries from you won't make much difference. Unless you are intending to save megabytes of information, which I doubt!

                          I don't know how you install your application to end users, but most Windows application installers delete application's registry key on uninstall.

                          S 1 Reply Last reply
                          3
                          • JonBJ JonB

                            @StudentScripter said in Save Programm Settings internally + how to organize with folders?:

                            @JonB How i the behaviour with qSetting when i allow it to do registry entrys. I don't want the endusers registry to get bloated over time.

                            I don't understand the question. But what I can say is: when you go to production/have end users under Windows they will expect you store settings in the Registry rather than .ini files (which you won't much know where to put anyway). So it's all very well for you to decide that in your development environment you (seem to) want to use .ini file so you can delete it, but I don;t think you should do that in production/release and that means you will have different paths of code.

                            QSettings is only saving downward from one registry key (as mentioned earlier) so it's not too "polluting", and you are using the same company/application name the whole time so that's it. As for "bloated", the registry will likely be GB rather than MB big, so a few entries from you won't make much difference. Unless you are intending to save megabytes of information, which I doubt!

                            I don't know how you install your application to end users, but most Windows application installers delete application's registry key on uninstall.

                            S Offline
                            S Offline
                            StudentScripter
                            wrote on last edited by
                            #17

                            @JonB @Pl45m4 Well thanks that answered my questions. :) Have a nice day.

                            1 Reply Last reply
                            0
                            • S StudentScripter has marked this topic as solved on
                            • S StudentScripter

                              @sierdzio

                              Something like this? And than remove this path at the end when my development is finished to save it in the users registry?

                                  QString filePath = "/path/to/your/settings.ini";
                                  QSettings settings(filePath, QSettings::IniFormat);
                              
                              
                              S Offline
                              S Offline
                              SimonSchroeder
                              wrote on last edited by
                              #18

                              @StudentScripter said in Save Programm Settings internally + how to organize with folders?:

                              QString filePath = "/path/to/your/settings.ini";

                              If you want to use an ini file, please use QStandardPath with ConfigLocation and don't invent your own place where to put the ini file.

                              1 Reply Last reply
                              2

                              • Login

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