Solved Emit QVector singal with a structure
-
Hi! I have a structure in
Worker.h
struct 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
QVector
with a structure toTest
class?Problem is, in
Test
slots:
void appData(QVector<AppsData> data);
AppsData
is not initialized.When I initialize it also in
Test
I 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
AppsData
twice. once insideWorker
scope and once insideTest
scope. 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 -
@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>
-
Thank you. The issue is fixed.