Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Default mechanism to store information

    General and Desktop
    3
    3
    512
    Loading More Posts
    • 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.
    • W
      WhatIf last edited by

      Hi,

      I need to store information to disk every time an app is used, a couple of lines, and I want the info to persist between each runs. Is there a better way than creating a file and writing to it?

      Also, is the best location to create this file is in the same directory as the executable will reside? But how to know where the executable will reside ahead of time?

      1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion last edited by

        No, you should not write in installation directory! Usually your application will not have write access there!
        Fot that kind of information you can use http://doc.qt.io/qt-5/qstandardpaths.html#writableLocation with QStandardPaths::AppLocalDataLocation as parameter to get the directory where your application should store such data. You should check at runtime whether this directory exists and create it if not.
        See here for more details: http://doc.qt.io/qt-5/qstandardpaths.html

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

        1 Reply Last reply Reply Quote 1
        • M
          michelson last edited by michelson

          You can try QSettingsas well .

          1 Reply Last reply Reply Quote 1
          • First post
            Last post