Qt Forum

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

    Unsolved How can I edit resource file?

    General and Desktop
    3
    3
    729
    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.
    • N
      neda last edited by

      Hi

      I have a XML file in some folder of my project.

      I can to read the file but I am not able to write.

      I have this error:

      QIODevice::write (QFile, ":\files\zoom.XML"): device not open

      void MyXML::save(){
      
          QFile file(":/files/zoom.XML");
          if (!file.open(QIODevice::WriteOnly | QFile::Text))
              return;
      
          QXmlStreamWriter xmlWriter(&file);
          xmlWriter.setAutoFormatting(true);
          xmlWriter.writeStartDocument();
      
          xmlWriter.writeStartElement("record");
      
          xmlWriter.writeAttribute("prop1",newProp1);
          ...
      	...
          xmlWriter.writeAttribute("propn",newPropn);
      
          xmlWriter.writeEndElement();
      }
      
      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You can't write in a resource file. It's built in your application.

        If you need a file that's modifiable, you should copy it in a standard application specific path that you can retrieve with QStandardPaths

        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 Reply Quote 1
        • dheerendra
          dheerendra Qt Champions 2022 last edited by

          Resource file is readonly file. You will not able to write this file.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

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