QProcess Operation
-
I want to run the touch screen calibration from my program. So, when the user hits the ts_calibrate button in my app, the calibration application should run and show its own screen. When the calibration is complete and the program terminates, execution should return to my app. My app should stall waiting for completion.
I tried using QProcess but I get a segmentation fault. Here is the code.
@void StartUp::on_ts_CalibrateButton_clicked()
{
QProcess *ts_calibrate;
ts_calibrate->start("ts_calibrate");if (!ts_calibrate->waitForStarted()) { qDebug() << "\nts_calibrate started"; } if (!ts_calibrate->waitForFinished()) { qDebug() << "ts_calibrate finished"; }
}@
ts_calibrate runs fine from the command prompt. I don't need any data transfer between my app and the calibration program.
What is the problem?
Thanks,
James -
You need to initialise your process:
@
QProcess *ts_calibrate = new QProcess();
@or just create it on a stack.
-
Thanks, that was a silly mistake.
Now, it crashes with a "User defined signal 2" on line "waitForStarted()". It does start the process as shown below.
@
840 ? 00:00:00 kworker/0:1
926 ? 00:00:00 ts_calibrate
927 pts/0 00:00:00 ps
root@dhcppc9:~#
@What am I doing wrong? Will this do what I want?
James
-
Can QProcess::execute() be useful ?
-
It should work the way you do it now, assuming QProcess can find the binary to run.
One correction: you are displaying qDebug() messages when the methods fail (exclamation mark at the beginning of the if expression).