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. Input from text file error !!!
Forum Update on Monday, May 27th 2025

Input from text file error !!!

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.1k Views
  • 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 Offline
    A Offline
    ahmed kato
    wrote on 30 Sept 2011, 07:42 last edited by
    #1

    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
    0
    • P Offline
      P Offline
      p-himik
      wrote on 30 Sept 2011, 07:57 last edited by
      #2

      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
      0
      • A Offline
        A Offline
        ahmed kato
        wrote on 30 Sept 2011, 08:21 last edited by
        #3

        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
        0
        • V Offline
          V Offline
          vsorokin
          wrote on 30 Sept 2011, 08:38 last edited by
          #4

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

          --
          Vasiliy

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ahmed kato
            wrote on 30 Sept 2011, 08:45 last edited by
            #5

            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
            0

            1/5

            30 Sept 2011, 07:42

            • Login

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