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 to Test 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 inside Worker scope and once inside Test 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


  • Moderators

    @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 that QVector<Worker::AppsData> is not the same as QVector<Test::AppsData>



  • @VRonin

    Thank you. The issue is fixed.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.