Hello,
I am trying to test an example from a book that is done with Qt3.
But it generates errors when i compiles it with Qt4.
This is the example:
and generated errors are:Code:
] #include <qapplication.h> #include <qfile.h> #include <qstring.h> #include <iostream> using namespace std; int main( int argc, char **argv ) { if( argc > 1 ) Filename = argv[1]; if( !file.open( IO_ReadOnly ) ) { cout << "Can't open" "the file " << Filename << endl; return 0; } QString ligne; while( !file.atEnd() ) { file.readLine(ligne, 512); qDebug("%s",ligne.latin1()); } file.close(); return 0; }
a.cpp:13: erreur: ‘IO_ReadOnly’ was not declared in this scope
a.cpp:16: erreur: no match for ‘operator<<’ in ‘std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(& std::cout)), ((const char*)"Impossible d\37777777742\37777777600\37777777631Can't open the file ")) << Filename’
a.cpp:23: erreur: no matching function for call to ‘QFile::readLine(QString&, int)’
a.cpp:24: erreur: ‘class QString’ has no member named ‘latin1’
make: *** [a.o] Erreur 1
In fact, i have tried to solve this errors using the docs of Qt4 but i can't.
Help please.