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. cannot use QVector as a parameter to signal
QtWS25 Last Chance

cannot use QVector as a parameter to signal

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 889 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.
  • G Offline
    G Offline
    GunkutA
    wrote on last edited by
    #1

    Hello, I am trying to send a QVector that consists of QStrings, by using signal-slot mechanism.
    I created the Signal as follows in header file:

    void sendInitDataToMath(QVector <QString> selectedNames);
    

    And this is the receiver slot declaration:

    void receiveInitData(QVector <QString> selectedNames);
    

    When I try to connect these signal and slot as

    void protocolForm::on_button_openMath_clicked()
    {
        mathFormInstance = new mathForm();
        mathFormInstance->show();
       connect(this,&protocolForm::sendInitDataToMath,mathFormInstance,&mathForm::receiveInitData);
    
    }
    

    I receive "undefined reference to 'protocolForm::sendInitDataToMath(QVector<QString>)' " error. Is this because we cannot use vector parameters as parameters to signal-slot? How can I solve that?

    J.HilkJ 1 Reply Last reply
    0
    • G GunkutA

      Hello, I am trying to send a QVector that consists of QStrings, by using signal-slot mechanism.
      I created the Signal as follows in header file:

      void sendInitDataToMath(QVector <QString> selectedNames);
      

      And this is the receiver slot declaration:

      void receiveInitData(QVector <QString> selectedNames);
      

      When I try to connect these signal and slot as

      void protocolForm::on_button_openMath_clicked()
      {
          mathFormInstance = new mathForm();
          mathFormInstance->show();
         connect(this,&protocolForm::sendInitDataToMath,mathFormInstance,&mathForm::receiveInitData);
      
      }
      

      I receive "undefined reference to 'protocolForm::sendInitDataToMath(QVector<QString>)' " error. Is this because we cannot use vector parameters as parameters to signal-slot? How can I solve that?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @GunkutA said in cannot use QVector as a parameter to signal:

      Is this because we cannot use vector parameters as parameters to signal-slot? How can I solve that?

      nope, it's because you forgot to #include<QVector>


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      G 1 Reply Last reply
      5
      • J.HilkJ J.Hilk

        @GunkutA said in cannot use QVector as a parameter to signal:

        Is this because we cannot use vector parameters as parameters to signal-slot? How can I solve that?

        nope, it's because you forgot to #include<QVector>

        G Offline
        G Offline
        GunkutA
        wrote on last edited by
        #3

        @J-Hilk But still the same error after I added #include <QVector>

        J.HilkJ 1 Reply Last reply
        0
        • G GunkutA

          @J-Hilk But still the same error after I added #include <QVector>

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @GunkutA depends on where you added that, sender and receiver class should know how to use QVector


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          G 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @GunkutA depends on where you added that, sender and receiver class should know how to use QVector

            G Offline
            G Offline
            GunkutA
            wrote on last edited by
            #5

            @J-Hilk Yes... that solved that. Thanks a lot.

            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