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. File position using QSettings
QtWS25 Last Chance

File position using QSettings

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.4k 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.
  • G Offline
    G Offline
    gRicky
    wrote on last edited by
    #1

    Hi All,

    I'm here again with my question.

    Provided that I'm working on Ubuntu OS, I'm using the QSettings objects to get some information are needed from my app to work properly. Now, I want to know if I write the code:

    @
    QSettings mySettings("myfile.ini", QSettings::IniFormat);
    @

    Where the QSettings look for the file which has to be open? I thought it was on the app folder but, it seems to be not like that.

    1 Reply Last reply
    0
    • napajejenunedk0N Offline
      napajejenunedk0N Offline
      napajejenunedk0
      wrote on last edited by
      #2

      See "QSettings":http://qt-project.org/doc/qt-4.8/QSettings.html documentation and more particularly the "this":http://qt-project.org/doc/qt-4.8/QSettings.html#locations-where-application-settings-are-stored section.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rcari
        wrote on last edited by
        #3

        It goes in your ~/.config folder, under a folder named after your "organizationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#organizationName-prop and a subfolder named after your "applicationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#applicationName-prop

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gRicky
          wrote on last edited by
          #4

          [quote author="napajejenunedk0" date="1350984657"]See "QSettings":http://qt-project.org/doc/qt-4.8/QSettings.html documentation and more particularly the "this":http://qt-project.org/doc/qt-4.8/QSettings.html#locations-where-application-settings-are-stored section.[/quote]

          I've already seen and read the Qt documentation about QSettings Obj.

          [quote author="rcari" date="1350984780"]It goes in your ~/.config folder, under a folder named after your "organizationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#organizationName-prop and a subfolder named after your "applicationName":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#applicationName-prop[/quote]

          I've not set the organizzationName and the applicationName and searching the ~/.config folder on my system I don't have any folder named like this.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alexisdm
            wrote on last edited by
            #5

            The QSetting constructor you are calling is using the file name as is, which means it looks for it in the current directory, which is more likely the directory you launched the application from, not necessarily the one where the application executable is. To get the latter you can use:

            @QSettings mySettings(QApplication::applicationDirPath() + "/myfile.ini", QSettings::IniFormat);@

            You would have to prefix explicitly the file path with QDesktopServices::storageLocation(QDesktopServices::DataLocation) (+ "/") instead to look for the file in ~/.config/organizationName/applicationName

            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