Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Chaining 2 connect statements

    General and Desktop
    2
    5
    340
    Loading More Posts
    • 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
      GCDX last edited by

      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.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @GCDX last edited by J.Hilk

        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

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

        1 Reply Last reply Reply Quote 2
        • G
          GCDX last edited by

          @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.Hilk 1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @GCDX last edited by

            @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

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

            1 Reply Last reply Reply Quote 2
            • G
              GCDX last edited by

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post