In following code I want to connect lambda function to QProcess::error signal:
void Updater::start() {
QProcess process;
QObject::connect(&process, &QProcess::error, [=] (QProcess::ProcessError error) {
qWarning() << "error " << error;
});
process.start("MyProgram");
process.waitForFinished();
}
But I get strange error:
error: no matching function for call to 'Updater::connect(QProcess* [unresolved overloaded function type], Updater::start()::)' });
What I do wrong here? The code executes inside method of class derived from QObject. The project configured to work with c++11.
I use Qt 5.3.1 on Linux x32 with gcc 4.9.2
Problem is that the
QProcess
has anothererror()
method, so compiler just doesn't know which method use. If you want to deal with overloaded methods, you should use next:Yes, it looks ugly, but there is no another way (only old syntax?).
This special line tells compiler that you want to use
void QProcess::error(QProcess::ProcessError error)
, so now there is no any ambiguityMore information you can find here.