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 Signal to boolean variable

Connect Signal to boolean variable

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 4.6k 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.
  • yczoY Offline
    yczoY Offline
    yczo
    wrote on last edited by
    #1

    That is my idea (mnC is an object in a paralel thread)

    connect(mnC,SIGNAL(connected(bool)),this->isConnected,SLOT(append(bool) ,Qt::QueuedConnection);

    Please can somebody help me to make a direct connection between the boolean "isConnected" in MainWindow and the signal "connected" in thread?

    Thanks in advance

    M jsulmJ p3c0P 3 Replies Last reply
    0
    • yczoY yczo

      That is my idea (mnC is an object in a paralel thread)

      connect(mnC,SIGNAL(connected(bool)),this->isConnected,SLOT(append(bool) ,Qt::QueuedConnection);

      Please can somebody help me to make a direct connection between the boolean "isConnected" in MainWindow and the signal "connected" in thread?

      Thanks in advance

      M Offline
      M Offline
      MartinD
      wrote on last edited by MartinD
      #2

      @yczo Why to complicate things? Just connect connected signal to a slot in "this" object which will set isConnected to the value passed via connected signal.

      1 Reply Last reply
      2
      • yczoY yczo

        That is my idea (mnC is an object in a paralel thread)

        connect(mnC,SIGNAL(connected(bool)),this->isConnected,SLOT(append(bool) ,Qt::QueuedConnection);

        Please can somebody help me to make a direct connection between the boolean "isConnected" in MainWindow and the signal "connected" in thread?

        Thanks in advance

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

        @yczo You cannot connect a signal to a variable. Signals are connected to slots (which are C++ methods).
        As @MartinD said add a slot with a bool parameter to your class and connect the signal to that slot. In the slot you then set your variable.

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

        1 Reply Last reply
        3
        • yczoY Offline
          yczoY Offline
          yczo
          wrote on last edited by
          #4

          Thank you very much all

          1 Reply Last reply
          1
          • yczoY yczo

            That is my idea (mnC is an object in a paralel thread)

            connect(mnC,SIGNAL(connected(bool)),this->isConnected,SLOT(append(bool) ,Qt::QueuedConnection);

            Please can somebody help me to make a direct connection between the boolean "isConnected" in MainWindow and the signal "connected" in thread?

            Thanks in advance

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            @yczo Well you can use C++11 features. Instead of creating a slot you can do:

            connect(mnC, &MNCClass::connected, [=](const bool status){
                 isConnected = status;
            });
            

            P.S: I don't know name of class which contains connected so used MNCClass. Change it to your actual classname.

            157

            1 Reply Last reply
            5

            • Login

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