PDA

View Full Version : cant open file newby problem



lmguru
27th January 2009, 13:44
Hi, I have some old program in C implementing in Qt4, an I`m trying to open file with fopen, and it give me errors when i compile it:


QString path, path2;
FILE *vstup;

path2 = lineEdit->text();
path = path2.section('/', -1); //it cuts from path to file the name of file name

vstup=fopen(path,"r");

The problem is in variable path, i don`t now how to convert it into right type for fopen. Thank`s you for any advice.

jpn
27th January 2009, 13:52
See QFile. Notice the example usage in detailed description part of the docs.

lmguru
27th January 2009, 14:40
Thank`s, I know about Qfile, but when I open text file with qfile, i don`t now equivalent to this C funktions:


c=fgetc(vstup);
and

fputc(c,vystup);

I was trying, it was something like this in Qfile:

c=getChar(vstup);
but its fo course not good

jpn
27th January 2009, 14:53
QFile inherits QIODevice. Most of the reading and writing functionality is available in QIODevice API. See QIODevice docs for more details.

PS. You're now dealing with C++. Refer to your favorite C++ book on how to call member functions...