Emit QVector singal with a structure
-
Hi! I have a structure in
Worker.hstruct AppsData { QIcon icon; QString name; QString version; QString publisher; QString installLocation; QString uninstallLocation; };and in signals:
void appData(QVector<AppsData> data);How to emit this
QVectorwith a structure toTestclass?Problem is, in
Testslots:
void appData(QVector<AppsData> data);AppsDatais not initialized.When I initialize it also in
TestI get error:error: C2338: Signal and slot arguments are not compatible. see reference to function template instantiation 'QMetaObject::Connection QObject::connect<void(__cdecl Worker::* )(QVector<Worker::AppsData>),void(__cdecl Test::* )(QVector<Test::AppsData>)>(const Worker *,Func1,const Test*,Func2,Qt::ConnectionType)' being compiled with [ Func1=void (__cdecl Worker::* )(QVector<Worker::AppsData>), Func2=void (__cdecl Test::* )(QVector<Test::AppsData>) ]How to fix it? Thanks.
-
You are declaring
AppsDatatwice. once insideWorkerscope and once insideTestscope. Even if they are identical the compiler rightfully considers them two different things. Just declare AppsData in a scope (the global one?) that can be accessible to every class that needs to use it -
Hi! I have a structure in
Worker.hstruct AppsData { QIcon icon; QString name; QString version; QString publisher; QString installLocation; QString uninstallLocation; };and in signals:
void appData(QVector<AppsData> data);How to emit this
QVectorwith a structure toTestclass?Problem is, in
Testslots:
void appData(QVector<AppsData> data);AppsDatais not initialized.When I initialize it also in
TestI get error:error: C2338: Signal and slot arguments are not compatible. see reference to function template instantiation 'QMetaObject::Connection QObject::connect<void(__cdecl Worker::* )(QVector<Worker::AppsData>),void(__cdecl Test::* )(QVector<Test::AppsData>)>(const Worker *,Func1,const Test*,Func2,Qt::ConnectionType)' being compiled with [ Func1=void (__cdecl Worker::* )(QVector<Worker::AppsData>), Func2=void (__cdecl Test::* )(QVector<Test::AppsData>) ]How to fix it? Thanks.
@Cobra91151 Can you shouw your code?
"Signal and slot arguments are not compatible" - says that the signatures of signal and slot do not match.
Be aware thatQVector<Worker::AppsData>is not the same asQVector<Test::AppsData> -
You are declaring
AppsDatatwice. once insideWorkerscope and once insideTestscope. Even if they are identical the compiler rightfully considers them two different things. Just declare AppsData in a scope (the global one?) that can be accessible to every class that needs to use itThank you. The issue is fixed.