Input from text file error !!!



  • 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]



  • 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.



  • 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



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.