Hello!
I'm trying to read a .txt file in my program, so, to do that i created a "Database/test.txt" file in "build-Loterias-Desktop-Debug" folder. When i run my program using QTCreator, he finds my .txt file, but when i run it directly without using QtCreator he finds nothing!
How can i solve the problem?
Here my code.
#define LF_PATH "Database/test.txt"
obj.createTestData( LF_PATH );
#define LF_PATH "Database/test.txt"
obj.createTestData( LF_PATH );
To copy to clipboard, switch view to plain text mode
void Test
::createTestData(QString filePath
) { if( !filePath.isEmpty( ) ) {
// Rest of the code...
file.close( );
}
}
}
void Test::createTestData(QString filePath) {
if( !filePath.isEmpty( ) ) {
QFile file( filePath );
if( file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
QTextStream stream( &file );
// Rest of the code...
file.close( );
}
}
}
To copy to clipboard, switch view to plain text mode
Thanks!
Bookmarks