PDA

View Full Version : Start application in QT



eltecprogetti
11th April 2012, 11:59
Hello,
I want to start an application in the same folder of my application in Debian, for example the calculator (gcalctool). In Windows I have no problem.
Where is may error?

QProcess *process = new QProcess(0);
QString folder = "";
process->start("gcalctool", QStringList() << folder);

wysota
11th April 2012, 13:06
You are using a path relative to your current working directory which might be different to what you are assuming. Better use an absolute path. You can use QCoreApplication::applicationDirPath() to get an absolute path to the directory containing your application binary.

eltecprogetti
12th April 2012, 09:46
I modified my code, and I write the absolute path:

QProcess *process = new QProcess(0);
process->start("/home/eltec/Programmi QT/Shell/calcolatrice");

"calcolatrice" is a "gcalctool" copy in the application folder ("/home/eltec/Programmi QT/Shell").

If I start "gcalctool", I have no problem, because this application is in the "/usr/bin" folder and Debian knows the system path.
But if I want to start an application with another path, the application do not start.
I repeat that "calcolatrice" is a "gcalctool" copy and it starts without problem if I double click on it.

Added after 8 minutes:

process->start("./gcalctool");

Debian start binary files only in the system path. With "./" I said Debian to start application in the current path.

Resolved, thanks.