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] What is the best path to save some settings/images in Windows?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] What is the best path to save some settings/images in Windows?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 3.3k 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    So in ubuntu it is home/.appname.. with the dot it makes it invisible for the user unless he press ctrl+h

    well in windows it is kinda ugly to have it at /username/.appname.. it is visible everytime and the only application in my computer doing this is gimp.. there must be a certain path in windows for that reason..

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Take a look at [[doc:QDesktopServices]]. It has a method to discover the path names to use for specific things. In your case, I would use QDesktopServices::DataLocation

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Landy
        wrote on last edited by
        #3

        I just have some research on this.
        in Windows, i mean, win7, there is a path named "%system%/users/%USERNAME%/AppData/". u can use this path to save your settings.
        there are 3 folder in this path, "local", "localLow", and "roaming".
        in roaming, it stores all settings for your apps, the files in this folder will not be removed.
        in others, it stores temp files for your apps, the files will be removed by some clean app.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Landy
          wrote on last edited by
          #4

          BTW, u can use QDir::homePath() to get current user path.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Leon
            wrote on last edited by
            #5

            [quote author="Andre" date="1348213480"]Take a look at [[doc:QDesktopServices]]. It has a method to discover the path names to use for specific things. In your case, I would use QDesktopServices::DataLocation[/quote]

            Andre

            @QString(QDesktopServices::DataLocation)@
            or
            @QString(QDesktopServices::displayName(QDesktopServices::DataLocation))@

            will return me an empty string. why is that?

            1 Reply Last reply
            0
            • L Offline
              L Offline
              Leon
              wrote on last edited by
              #6

              [quote author="Landy" date="1348215176"]I just have some research on this.
              in Windows, i mean, win7, there is a path named "%system%/users/%USERNAME%/AppData/". u can use this path to save your settings.
              there are 3 folder in this path, "local", "localLow", and "roaming".
              in roaming, it stores all settings for your apps, the files in this folder will not be removed.
              in others, it stores temp files for your apps, the files will be removed by some clean app.
              [/quote]

              i want to make the application cross platform so i can't do that...

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                [quote author="Leon" date="1348215468"]
                [quote author="Andre" date="1348213480"]Take a look at [[doc:QDesktopServices]]. It has a method to discover the path names to use for specific things. In your case, I would use QDesktopServices::DataLocation[/quote]

                Andre

                @QString(QDesktopServices::DataLocation)@
                or
                @QString(QDesktopServices::displayName(QDesktopServices::DataLocation))@

                will return me an empty string. why is that?

                [/quote]

                Because that is not how you use these constants. You should use them as the argument for the storageLocation() method of that class.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  Leon
                  wrote on last edited by
                  #8

                  Xmm ok it works but 2 questions..
                  Windows uses backslashes but Ubuntu us slash.. will this be a problem if u use slashes in windows?

                  because for example telling qdir to create this folder
                  @C:\Users\CityBong\AppData\Local/.appname/@
                  will work perfectly.. but this won't work always? that's why i am asking..

                  And 2nd question, as i said in Ubuntu it is home/.appname.. with the dot it makes it invisible for the user unless he press ctrl+h... ok? But in Windows creating a folder at C:\Users\CityBong\AppData\Local
                  with a dot isn't the correct i quess.. all the apps there aren't starting with a dot.. Any ideas?

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    Within your application, Qt recommends you use forward slashes for paths on all operating systems. Translate from 'native' on user input, and translate back to native for display or external tools that expect a certain format. Internally in Qt, you can use forward slashes everywhere.

                    On your hidden question: on windows, the AppData directory itself is already hidden.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Leon
                      wrote on last edited by
                      #10

                      Ok, i appreciate your answers Andre! Thanks.

                      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