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. Standard path save location
Qt 6.11 is out! See what's new in the release blog

Standard path save location

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 937 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.
  • naaxN Offline
    naaxN Offline
    naax
    wrote on last edited by naax
    #1

    Hello guys, Can you help me with how I can save my data on every device using a standard path?
    I think the best location to save is my application folder.

    
        QFile file("C:/Users/<USER>/Documents");
        if (file.open(QIODevice::WriteOnly | QIODevice::Text))
        {
            qDebug() << "SAVED";
                QTextStream stream(&file);
    ....
    
    1 Reply Last reply
    0
    • naaxN naax

      @jsulm

          QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
      

      I'm trying this actually, but i cant delete -j
      https://forum.qt.io/topic/40720/permission-denied

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

      @naax You are trying to open a directory like a file.
      Add a file name you want to use:

      QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/somefile.txt");
      

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

      naaxN 1 Reply Last reply
      4
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        Golden rule of Qt is: when you need a class, search the docs for the first name that comes to your head :-)

        And there is, just like you guessed, a class named QStandardPaths.

        You need to use the writableLocation() function.

        (Z(:^

        naaxN 1 Reply Last reply
        3
        • sierdzioS sierdzio

          Golden rule of Qt is: when you need a class, search the docs for the first name that comes to your head :-)

          And there is, just like you guessed, a class named QStandardPaths.

          You need to use the writableLocation() function.

          naaxN Offline
          naaxN Offline
          naax
          wrote on last edited by
          #3

          @sierdzio
          Nice, I got it, but "Access is denied."

          I have Antivirus turned off but still the same problem.

          jsulmJ 1 Reply Last reply
          0
          • naaxN naax

            @sierdzio
            Nice, I got it, but "Access is denied."

            I have Antivirus turned off but still the same problem.

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

            @naax said in Standard path save location:

            "Access is denied."

            What is the patch you're trying to access when you get this error?

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

            naaxN 1 Reply Last reply
            0
            • jsulmJ jsulm

              @naax said in Standard path save location:

              "Access is denied."

              What is the patch you're trying to access when you get this error?

              naaxN Offline
              naaxN Offline
              naax
              wrote on last edited by
              #5

              @jsulm

                  QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
              

              I'm trying this actually, but i cant delete -j
              https://forum.qt.io/topic/40720/permission-denied

              jsulmJ 1 Reply Last reply
              0
              • naaxN naax

                @jsulm

                    QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
                

                I'm trying this actually, but i cant delete -j
                https://forum.qt.io/topic/40720/permission-denied

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

                @naax You are trying to open a directory like a file.
                Add a file name you want to use:

                QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/somefile.txt");
                

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

                naaxN 1 Reply Last reply
                4
                • jsulmJ jsulm

                  @naax You are trying to open a directory like a file.
                  Add a file name you want to use:

                  QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/somefile.txt");
                  
                  naaxN Offline
                  naaxN Offline
                  naax
                  wrote on last edited by naax
                  #7

                  @jsulm

                  Ok, it's work. If I want to load it I'm using the same function, right?

                  jsulmJ 1 Reply Last reply
                  0
                  • naaxN naax

                    @jsulm

                    Ok, it's work. If I want to load it I'm using the same function, right?

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

                    @naax yes

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

                    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