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. Connect overloaded signals to overloaded slots
QtWS25 Last Chance

Connect overloaded signals to overloaded slots

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 666 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by Mark81
    #1

    I have two signals:

    void write(int address, QString type, QVariant value, bool ws);
    void write(int address, QVariant value);
    

    and in another class the two related slots:

    void modbus_write(int address, QString type, QVariant value, bool ws);
    void modbus_write(int address, QVariant value);
    

    I want to connect each signal to its slot. I tried:

    connect(&manager, QOverload<int, QVariant>::of(&Manager::write), this, QOverload<int, QVariant>::of(&Engine::modbus_write));
    connect(&manager, QOverload<int, QString, QVariant, bool>::of(&Manager::write), this, QOverload<int, QString, QVariant, bool>::of(&Engine::modbus_write));
    

    but the compiler says:

    Invalid use of incomplete type 'class QVariant'

    referred to the moc_ file.
    In my class I put at the top:

    #include <QVariant>
    

    What is the right syntax here?

    J.HilkJ 1 Reply Last reply
    0
    • M Mark81

      I have two signals:

      void write(int address, QString type, QVariant value, bool ws);
      void write(int address, QVariant value);
      

      and in another class the two related slots:

      void modbus_write(int address, QString type, QVariant value, bool ws);
      void modbus_write(int address, QVariant value);
      

      I want to connect each signal to its slot. I tried:

      connect(&manager, QOverload<int, QVariant>::of(&Manager::write), this, QOverload<int, QVariant>::of(&Engine::modbus_write));
      connect(&manager, QOverload<int, QString, QVariant, bool>::of(&Manager::write), this, QOverload<int, QString, QVariant, bool>::of(&Engine::modbus_write));
      

      but the compiler says:

      Invalid use of incomplete type 'class QVariant'

      referred to the moc_ file.
      In my class I put at the top:

      #include <QVariant>
      

      What is the right syntax here?

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

      @Mark81 said in Connect overloaded signals to overloaded slots:

      #include <QVariant>

      did you include that in the headers of the emitter and receiver?


      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.

      M 1 Reply Last reply
      3
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3
        This post is deleted!
        M 1 Reply Last reply
        2
        • VRoninV VRonin

          This post is deleted!

          M Offline
          M Offline
          Mark81
          wrote on last edited by
          #4

          @VRonin said in Connect overloaded signals to overloaded slots:

          The connect doesn't match... QOverload<int, QVariant>::of(&Engine::writeModbus)?

          Yep, this was actually a typo due to the launch break :) I didn't recall the actual name and made a mess.

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

            @Mark81 said in Connect overloaded signals to overloaded slots:

            #include <QVariant>

            did you include that in the headers of the emitter and receiver?

            M Offline
            M Offline
            Mark81
            wrote on last edited by
            #5

            @J-Hilk said in Connect overloaded signals to overloaded slots:

            did you include that in the headers of the emitter and receiver?

            Got it!
            It's weird because usually it tells me the exact file where the include is missing. This time it talked about the moc_ file and because I was unsure about the syntax I forgot to check it.

            1 Reply Last reply
            2

            • Login

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