How to connect a custom message lambda
-
this->connect(cGlobalParam::Communicator()->worker, QOverload<Standard_MeasureDataReceive*>::of(&TcpClientThreadDoWork::Signal_MeasureDataReceive), [=](Standard_MeasureDataReceive* data) { }); class TcpClientThreadDoWork : public QObject { public: signals: void Signal_MeasureDataReceive(Standard_MeasureDataReceive* e); };
There is no error in the code itself, but an error occurs when compiling.
What is the cause of the link error?오류 LNK2019 "public: void __cdecl TcpClientThreadDoWork::Signal_MeasureDataReceive(class Standard_MeasureDataReceive *)" (?Signal_MeasureDataReceive@TcpClientThreadDoWork@@QEAAXPEAVStandard_MeasureDataReceive@@@Z)"public: virtual void __cdecl wStandardCurve::Initialize(void)" (?Initialize@wStandardCurve@@UEAAXXZ)
MainWidget D:\ProgramSrc\POP\MainWidget\wStandardCurve.obj 1
오류 LNK2001 확인할 수 없는 외부 기호 "public: static struct QMetaObject const TcpClientThreadDoWork::staticMetaObject" (?staticMetaObject@TcpClientThreadDoWork@@2UQMetaObject@@B) MainWidget D:\ProgramSrc\POP\MainWidget\wStandardCurve.obj 1
오류 LNK1120 MainWidget D:\ProgramSrc\POP\Depoly_Exec\debug\MainWidget.exe 1 -
this->connect(cGlobalParam::Communicator()->worker, SIGNAL(Signal_MeasureDataReceive(Standard_MeasureDataReceive)), this, SLOT(Communicator_Event_MeasureDataReceive(Standard_MeasureDataReceive)));
If you declare and use it like this, it works normally.
-
-
@IknowQT said in How to connect a custom message lambda:
I think there must have been a problem when it was used as a commonly used connect function
if you're using Qt5 connect syntax yes, with the Qt4 one above, not necessarily (straight away)
-
@IknowQT said in How to connect a custom message lambda:
has been declared. If it is not declared, I think there must have been a problem when it was used as a commonly used connect function, not a lambda function.
No necessary, when using
SLOT()
andSIGNAL()
for the connect, there is no check done during compilation, only on runtime.
signal / slot validity check on compilation is only done with new connection syntax. -
this->connect(cGlobalParam::Communicator()->worker, SIGNAL(Signal_MeasureDataReceive(Standard_MeasureDataReceive)), this, SLOT(Communicator_Event_MeasureDataReceive(Standard_MeasureDataReceive))); void wStandardCurve::Communicator_Event_MeasureDataReceive(const Standard_MeasureDataReceive data) { emit UserDefine_ReceiveData(data); } this->connect(this, &wStandardCurve::UserDefine_ReceiveData, [&](const Standard_MeasureDataReceive data) { rcvData = data; });
Communicator_Event_MeasureDataReceive -> UserDefine_ReceiveData -> lamba Func
So what's the problem?
I did one test. I generated singnal one more time and connected it with a lambda. It connects normally.The goal I want to use is to use the signal without going through it once more.
-
@IknowQT said in How to connect a custom message lambda:
The goal I want to use is to use the signal without going through it once more
You can connect signals with other signals, not only signals with slots...
-
@IknowQT said in How to connect a custom message lambda:
So what's the problem?
I did one test. I generated singnal one more time and connected it with a lambda. It connects normally.I am a little bit lost, is the signal signature
Signal_MeasureDataReceive(Standard_MeasureDataReceive)
orSignal_MeasureDataReceive(Standard_MeasureDataReceive*)
? -
@KroMignon said in How to connect a custom message lambda:
I am a little bit lost, is the signal signature Signal_MeasureDataReceive(Standard_MeasureDataReceive) or Signal_MeasureDataReceive(Standard_MeasureDataReceive*) ?
To be exact, Signal_MeasureDataReceive(Standard_MeasureDataReceive).
-
@IknowQT said in How to connect a custom message lambda:
@KroMignon said in How to connect a custom message lambda:
I am a little bit lost, is the signal signature Signal_MeasureDataReceive(Standard_MeasureDataReceive) or Signal_MeasureDataReceive(Standard_MeasureDataReceive*) ?
To be exact, Signal_MeasureDataReceive(Standard_MeasureDataReceive).
why do you tell the QOverload and the lambda argument that its a pointer?
QOverload<Standard_MeasureDataReceive*>::of(&TcpClientThreadDoWork::Signal_MeasureDataReceive), [=](Standard_MeasureDataReceive* data)