Connect SIGNAL from object to Lambda in main(). How?
-
wrote on 7 Nov 2019, 14:12 last edited by bogong 11 Jul 2019, 14:23
Hello all!
What is there right way to call lambda function in Main by connecting it to signal?int main(int inCounter, char *inArguments[]) { ... Object* oObject = new aObject(); QObject::connect(oObject,SIGNAL(signal()),???,???); ... }
I've been trying to connect in following manual but it's not working.
QObject::connect( oObject3,SIGNAL(sCreated()), [](){ aLOG << "1111"; } );
There are this error:
../Plain/main.cpp:32:3: error: no matching function for call to 'connect' QObject::connect( ^~~~~~~~~~~~~~~~ /Users/alexandr/Tools/Qt/5.12.5/clang_64/lib/QtCore.framework/Headers/qobject.h:463:41: note: candidate function not viable: no known conversion from '(lambda at ../Plain/main.cpp:34:4)' to 'const char *' for 3rd argument inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
-
Hello all!
What is there right way to call lambda function in Main by connecting it to signal?int main(int inCounter, char *inArguments[]) { ... Object* oObject = new aObject(); QObject::connect(oObject,SIGNAL(signal()),???,???); ... }
I've been trying to connect in following manual but it's not working.
QObject::connect( oObject3,SIGNAL(sCreated()), [](){ aLOG << "1111"; } );
There are this error:
../Plain/main.cpp:32:3: error: no matching function for call to 'connect' QObject::connect( ^~~~~~~~~~~~~~~~ /Users/alexandr/Tools/Qt/5.12.5/clang_64/lib/QtCore.framework/Headers/qobject.h:463:41: note: candidate function not viable: no known conversion from '(lambda at ../Plain/main.cpp:34:4)' to 'const char *' for 3rd argument inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
wrote on 7 Nov 2019, 14:20 last edited by@bogong
with the new signal/slot syntaxQObject* oObject = new QObject(); QObject::connect(oObject,&QObject::destroyed,[](){ qDebug()<< "object destructed"; }); oObject->deleteLater();
-
wrote on 7 Nov 2019, 14:38 last edited by
Issue closed.
-
wrote on 2 May 2025, 17:33 last edited by Perdrix 5 Feb 2025, 17:36This post is deleted!