PDA

View Full Version : How to read text only as it is from file



thomasjoy
8th August 2007, 15:57
hi all
i am working on mac OSX and using QT 4.1
firstly i am selecting a file , from QFileDialog ::getOpenFileName, to read
i am getting the whole text data in String but not as same as it is in File
like if in a file i have spaces an freeline(line without characters),or if data is in next line then it show in next line
but in my case its not happening same....

so now i want to get the data as it is ,as it is in file (which is selected from QFileDialog:: getOpenFileName).

waiting for your co-ordination :)

TIA

marcel
8th August 2007, 16:10
How do you exactly read the data?

Try using setTextModeEnabled(true) and using QFile::readAll. It returns a QByteArray, from which you can build a QString.
Anyway, reading an entire file in a single pass is not a good idea, since it can be pretty big.

If it still doesn't work,. then post some code.

Regards

marcel
8th August 2007, 16:14
Or use a QTextStream on the file and use readAll. It returns a QString.

Regards

thomasjoy
9th August 2007, 09:47
now, tell me i have a buffer of data that has been read
tell how i can set that data in treeWidget's coloumn which is in buffer
and buffer is of const char * type....
do tell me is there any direct way or indirect way(using any diffrent metthod like getting each byte and setting to desired location)...


to read the data i had used the basic c operation fopen,fread...

TIA