Skip to content
Advertisement

Executable file didn’t work correctly [Linux]

I write a program on Qt C++ GUI, that from given user input generates three .cpp files with proper syntax (C++). When I start my program from Qt Creator directly or run it from console like a script its creates the files in executable directory correctly:

QDir().mkdir(QDir::currentPath() + "/Files");
QFile outputFile(QDir::currentPath() + "/Files/myFile.cpp");

When I double click executable file, the program starts and work fine, but It didn’t create my files.

I am using Linux Debian Squeezy 6.0 and Qt Creator 4.6.3

Advertisement

Answer

I think when you double click on the executable files are created, but not at the desired directory as the current directory in that case is different. You should use QCoreApplication::applicationDirPath() instead of QDir::currentPath().

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement