I am trying to run a command line program, gphoto2 from my Qt app running in Linux and read the results that it outputs to Standard Output and Standard Error. The GUI in th
I had the same issue. I think it happens because finished signal function is overloaded with 2 signatures and the compiler has trouble to infer the type:
void finished(int exitCode);
void finished(int exitCode, QProcess::ExitStatus exitStatus);
Here is my quick-and-dirty workaround:
1) Open qprocess.h
2) Comment the "shorter" signatures:
// void finished(int exitCode);
3) Then connect finished-signal with your lambda slot:
QObject::connect(&process, &QProcess::finished, [=](int exitCode, QProcess::ExitStatus exitStatus){
qDebug() << "finished. Exit code: " + exitCode ;
});
I believe the following will work:
connect(cameraControl, SIGNAL(finished(int , QProcess::ExitStatus )), this, SLOT(on_cameraControlExit(int , QProcess::ExitStatus )));
Or with C++14 (modern compilers)
QObject::connect(cameraControl, qOverload<int, QProcess::ExitStatus >(&QProcess::finished), this, &MainWindow::on_cameraControlExit);
Or in the Qt5 convention:
QObject::connect(cameraControl, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &MainWindow::on_cameraControlExit);