Qt Forum

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

    Call for Presentations - Qt World Summit

    Input from text file error !!!

    General and Desktop
    3
    5
    1861
    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.
    • A
      ahmed kato last edited by

      i have a strange problem here, my program must read and write in a text file...so i have added this file to resources..but it is not editable ..

      @
      QFile File(:/Files/Data/Rigs.txt)
      @

      ...so any edit are done outside the program....and when i do this code

      @QFile File(/Data/Rigs.txt)@

      it does not work as my software don't find the specified file...this file is in a folder inside my qt program folder....any siggestions??!!!

      [EDIT: fixed code formatting, Volker]

      Ahmed Kato
      Computer & communications student
      Intern and MSP at Microsoft

      1 Reply Last reply Reply Quote 0
      • P
        p-himik last edited by

        As i know resources are read-only:

        bq. The Qt resource system is a platform-independent mechanism for storing binary files in the application's executable. This is useful if your application always needs a certain set of files (icons, translation files, etc.) and you don't want to run the risk of losing the files.

        If you want to edit some file you don't need to add it to your resources. You just need to create QFile with a path to that file. The path can be either relative or absolute.

        1 Reply Last reply Reply Quote 0
        • A
          ahmed kato last edited by

          so...if the file is in a folder called data in the software folder...what is the path??
          i tried QFile file(/Data/filename) it don't work :S

          Ahmed Kato
          Computer & communications student
          Intern and MSP at Microsoft

          1 Reply Last reply Reply Quote 0
          • V
            vsorokin last edited by

            Try
            @QFile file(qApp->applicationDirPath() + "/Data/filename")@

            --
            Vasiliy

            1 Reply Last reply Reply Quote 0
            • A
              ahmed kato last edited by

              now i know where is the problem...thx vass :D:D

              Ahmed Kato
              Computer & communications student
              Intern and MSP at Microsoft

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