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. Chaining 2 connect statements
QtWS25 Last Chance

Chaining 2 connect statements

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 637 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
    GCDX
    wrote on last edited by
    #1

    Hi everyone,
    I've been trying to connect 2 functions with signal and slots but i can't seem to do it that i've put as buttons.

    It is basically 2 parsing functions that i want to work in tandem but i can't seem to write a third connect statement that will join all of them together.
    connect(innerPage, SIGNAL(loadFinished(bool)), SLOT(parse(bool)));
    connect(innerPage2, SIGNAL(loadFinished(bool)), SLOT(parse2(bool)));

    I thought it would be simply
    connect(this,SIGNAL(parse(bool)),innerPage2,SLOT(on_pushButton_clicked());

    Can someone enlighten me?

    J.HilkJ 1 Reply Last reply
    0
    • G GCDX

      Hi everyone,
      I've been trying to connect 2 functions with signal and slots but i can't seem to do it that i've put as buttons.

      It is basically 2 parsing functions that i want to work in tandem but i can't seem to write a third connect statement that will join all of them together.
      connect(innerPage, SIGNAL(loadFinished(bool)), SLOT(parse(bool)));
      connect(innerPage2, SIGNAL(loadFinished(bool)), SLOT(parse2(bool)));

      I thought it would be simply
      connect(this,SIGNAL(parse(bool)),innerPage2,SLOT(on_pushButton_clicked());

      Can someone enlighten me?

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

      hi @GCDX
      first, I'm guessing its a copy past error, but those two connect statements are wrong, they are missing a 4th parameter.

      connect(innerPage, SIGNAL(loadFinished(bool)), SLOT(parse(bool)));
      connect(innerPage2, SIGNAL(loadFinished(bool)), SLOT(parse2(bool)));

      I thought it would be simply
      connect(this,SIGNAL(parse(bool)),innerPage2,SLOT(on_pushButton_clicked());

      Can someone enlighten me?

      parse(bool) is obviously a SLOT, you connected to it as a slot previously, so you can't "listen" to the signal or connect to to it

      QObject::Connect allows the combination of SIGNAL -> SLOT, SIGNAL -> SIGNAL and since Qt5 and the new Syntax SIGNAL -> Any function, SIGNAL -> Lambda expression.

      But in all cases the origin has to be a defined QT-SIGNAL you cant connect 2 functions together.


      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.

      1 Reply Last reply
      2
      • G Offline
        G Offline
        GCDX
        wrote on last edited by
        #3

        @J-Hilk its not a copy paste error, it works, the lack of parameter put it to default this i think. So theres no solution to this???

        The idea i'm trying to achieve is, i need to access a webpage to parse some information and the parsed information is needed as arguments to access another webpage so that i can parse more information. Currently, this works with 2 buttons, one button to parse the first webpage and the second button when i want to parse more information from the next webpage.

        I was trying to automate it, but can't find a solution.

        J.HilkJ 1 Reply Last reply
        0
        • G GCDX

          @J-Hilk its not a copy paste error, it works, the lack of parameter put it to default this i think. So theres no solution to this???

          The idea i'm trying to achieve is, i need to access a webpage to parse some information and the parsed information is needed as arguments to access another webpage so that i can parse more information. Currently, this works with 2 buttons, one button to parse the first webpage and the second button when i want to parse more information from the next webpage.

          I was trying to automate it, but can't find a solution.

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

          @GCDX
          you're right, theres actually a 3 parameter overload of connect

          bool QObject::connect(const QObject * sender, const char * signal, const char * method, Qt::ConnectionType type = Qt::AutoConnection) const
          

          Well, you can simply go the way of a custom signal, that you emit at the end of the parse(bool) slot, or since slots are basicaly functions, you can just call on_pushButton_clicked() at the end of parse


          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.

          1 Reply Last reply
          2
          • G Offline
            G Offline
            GCDX
            wrote on last edited by
            #5

            @J-Hilk silly me, that was the easiest solution did i didnt think about. Thanks!

            1 Reply Last reply
            0

            • Login

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