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. Resources problem
Qt 6.11 is out! See what's new in the release blog

Resources problem

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 481 Views 2 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
    #1

    Hello.

    In my last project, I didn't have any problems with Save data to my .txt file in project resources.
    This time this not working and I don't know why. I used .errorString() and i got "Unknown Error"
    If I save it not to resources, but to my local path then all works.

    ee.png

     QFile file(":/bin/Profile.txt");
     
        if (file.open(QIODevice::WriteOnly | QIODevice::Text))
        {
                QTextStream stream(&file);
                stream << ui->ShowName->text()<< '\n';
                stream << Euro << "\n";
                stream << Streak << "\n";
                stream << isDataCorrect <<"\n";
                stream << Tasks[0] <<"\n";
                stream << Tasks[1] <<"\n";
                stream << Tasks[2] <<"\n";
                stream << Tasks[3] <<"\n";
                stream << Tasks[4] <<"\n";
                stream << isAccountCreated<<"\n";
        }
        else
            qDebug() << file.errorString();
    }
    
    1 Reply Last reply
    0
    • naaxN naax

      What I can do? My project will be used on other devices and I want to save this data somewhere.

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

      @naax

      Use program directories or any default path, specified by path variables (User dir, home dir, program files, etc.) and save your file, which seems to be a config file, there.

      https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum


      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
      4
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        You can't open a resource file in write mode.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        3
        • naaxN Offline
          naaxN Offline
          naax
          wrote on last edited by
          #3

          What I can do? My project will be used on other devices and I want to save this data somewhere.

          Pl45m4P 1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            But not in a compiled-in resource file...

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • naaxN naax

              What I can do? My project will be used on other devices and I want to save this data somewhere.

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

              @naax

              Use program directories or any default path, specified by path variables (User dir, home dir, program files, etc.) and save your file, which seems to be a config file, there.

              https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum


              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
              4
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                Hi,

                I'd rather avoid the program directory as application are usually installed in folders that have write restrictions. As @Pl45m4 suggested, use QStandardPaths to get a suitable write location.

                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
                0

                • Login

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