Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Waiting for qt signal in c++ function
QtWS25 Last Chance

Waiting for qt signal in c++ function

Scheduled Pinned Locked Moved Solved C++ Gurus
9 Posts 3 Posters 786 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.
  • N Offline
    N Offline
    NewbieQTUser
    wrote on last edited by
    #1

    Hi,
    im search way to recive signal from qt object in c++

    fnx(){
    QSharedPointer client; //pointer to qt object
    client->doSomeWork(); //its emit done when finished.
    ...
    next operations.
    }

    Chris KawaC 1 Reply Last reply
    0
    • N NewbieQTUser

      Its function only, but i will try pass it to doSomeWork, thanks for help :)

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #8

      @NewbieQTUser You can also connect a function:

      void fnx()
      {
          client->doSomeWork();
          QObject::connect(client, &ClientClass::done, &doStuff);
      }
      
      void doStuff()
      {
          // following operations
      }
      
      N 1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Why not connect that signal to a function that will continue the processing ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • N NewbieQTUser

          Hi,
          im search way to recive signal from qt object in c++

          fnx(){
          QSharedPointer client; //pointer to qt object
          client->doSomeWork(); //its emit done when finished.
          ...
          next operations.
          }

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #3
          void MyClass::fnx()
          {
              client->doSomeWork();
              connect(client, &ClientClass::done, this, &MyClass::doStuff);
          }
          
          void MyClass::doStuff()
          {
              // following operations
          }
          
          1 Reply Last reply
          0
          • N Offline
            N Offline
            NewbieQTUser
            wrote on last edited by
            #4

            Im calling it from generic c++ app, i cant use connect syntax

            Chris KawaC SGaistS 2 Replies Last reply
            0
            • N NewbieQTUser

              Im calling it from generic c++ app, i cant use connect syntax

              Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @NewbieQTUser What do you mean you can't? If client emits a signal it means it's a QObject. If you're accessing QObjects you can access connect. Qt is generic C++, so could you explain what's your problem exactly?

              1 Reply Last reply
              2
              • N NewbieQTUser

                Im calling it from generic c++ app, i cant use connect syntax

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                connect is a static method so you still can.

                Otherwise, you can pass that method to your doSomeWork function so that it can be connected to by your class.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                N 1 Reply Last reply
                1
                • SGaistS SGaist

                  connect is a static method so you still can.

                  Otherwise, you can pass that method to your doSomeWork function so that it can be connected to by your class.

                  N Offline
                  N Offline
                  NewbieQTUser
                  wrote on last edited by
                  #7

                  Its function only, but i will try pass it to doSomeWork, thanks for help :)

                  Chris KawaC 1 Reply Last reply
                  0
                  • N NewbieQTUser

                    Its function only, but i will try pass it to doSomeWork, thanks for help :)

                    Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @NewbieQTUser You can also connect a function:

                    void fnx()
                    {
                        client->doSomeWork();
                        QObject::connect(client, &ClientClass::done, &doStuff);
                    }
                    
                    void doStuff()
                    {
                        // following operations
                    }
                    
                    N 1 Reply Last reply
                    1
                    • Chris KawaC Chris Kawa

                      @NewbieQTUser You can also connect a function:

                      void fnx()
                      {
                          client->doSomeWork();
                          QObject::connect(client, &ClientClass::done, &doStuff);
                      }
                      
                      void doStuff()
                      {
                          // following operations
                      }
                      
                      N Offline
                      N Offline
                      NewbieQTUser
                      wrote on last edited by
                      #9

                      @Chris-Kawa said in Waiting for qt signal in c++ function:

                      @NewbieQTUser You can also connect a function:

                      void fnx()
                      {
                          client->doSomeWork();
                          QObject::connect(client, &ClientClass::done, &doStuff);
                      }
                      
                      void doStuff()
                      {
                          // following operations
                      }
                      

                      Also thx, looks like a good solution

                      1 Reply Last reply
                      0
                      • N NewbieQTUser has marked this topic as solved on

                      • Login

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