Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Emit QVector singal with a structure
Forum Updated to NodeBB v4.3 + New Features

Emit QVector singal with a structure

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by Cobra91151
    #1

    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.

    jsulmJ 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      Cobra91151C 1 Reply Last reply
      5
      • Cobra91151C Cobra91151

        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.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #3

        @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>

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • VRoninV VRonin

          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

          Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #4

          @VRonin

          Thank you. The issue is fixed.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved