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. Writing file and opening file working on dev but not on release.
Forum Updated to NodeBB v4.3 + New Features

Writing file and opening file working on dev but not on release.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 249 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.
  • N Offline
    N Offline
    NicolasR
    wrote on last edited by
    #1

    Hello everyone,
    I'm developing a simple app on my Mac.
    With a QplaintTextEdit, I write in file, and at the opening of the app I read the file to inject it in the editor
    When I run the app from QtEditor everything is working fine.

    But If I go into the folders generated by QtEditor (release/profile/debug) and start the app, nothing is write in the file. (there no file btw)

    So I opened the mac package and I see my "note.txt" but the only text that is in it, is the text I wrote when I launched the app with QtEditor, not with app generated by Qt.

    I hope it is a little bit clear.... Cause I don't find the problem :)

    I create a file with a simple

    QFile file("note.txt")
    

    No other path.
    Maybe I need to set another directory like /opt or something else ? But If I run the app on windows, I don't know what will happen .

    Thanks in advance.
    Nicolas.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      The rule is: do not create files relative to the executable. Most of the time your users will not have write permissions in that folder. You should use QStandardPaths to query a suitable folder for that like the Documents folder.

      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
      1
      • N Offline
        N Offline
        NicolasR
        wrote on last edited by
        #3

        Thanks it's working :)

          QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
            QFile file(path + "note.txt");
        
        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