qt - Error while connecting lambda function to QProcess::error -


in following code want connect lambda function 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 strange error:

error: no matching function call 'updater::connect(qprocess* [unresolved overloaded function type], updater::start()::)' });

what wrong here? code executes inside method of class derived qobject. project configured work c++11.

i use qt 5.3.1 on linux x32 gcc 4.9.2

problem qprocess has error() method, compiler doesn't know method use. if want deal overloaded methods, should use next:

qprocess process; connect(&process, static_cast<void (qprocess::*)(qprocess::processerror)> (&qprocess::error), [=](qprocess::processerror perror) {     qwarning() << "error " << perror; }); process.start("myprogram"); process.waitforfinished(); 

yes, looks ugly, there no way (only old syntax?).

this special line tells compiler want use void qprocess::error(qprocess::processerror error), there no ambiguity

more information can find here.


Comments