connect a signal to lambda function
Solved
General and Desktop
-
Hi,
I'm trying to connect a signal to a lambda function like this://main.cpp FileLoader fl; QObject::connect( fl, &FileLoader::objChanged, [=]( const QString &newValue ) { qDebug()<< "lambda called..";} );
the signal is defined like this :
void objChanged(QString)
this is the output :
C:\udp_inspector\main.cpp:25: erreur : no matching function for call to 'QObject::connect(FileLoader&, void (FileLoader::*)(QString), qMain(int, char**)::<lambda(QString)>)' QObject::connect(fl,FileLoader::objChanged,[=](QString newObj){qDebug()<<newObj;}); ^
Can someone tell me how to do this please ?
-
The first argument must be a pointer to QObject.
ChangeQObject::connect(fl, &FileLoader::objChanged, [=]( const QString &newValue ) { qDebug()<< "lambda called..";});
toQObject::connect(&fl, &FileLoader::objChanged, [=]( const QString &newValue ) { qDebug()<< "lambda called..";});