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. QSignalSpy to receive signals for particular time instead of count
Forum Updated to NodeBB v4.3 + New Features

QSignalSpy to receive signals for particular time instead of count

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsignalspytest automation
6 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • V Offline
    V Offline
    Venkateswaran
    wrote on last edited by
    #1

    is possible to make the QSignalSpy wait for a particular time until it receives the specific signal. Right now I have this function which waits for the particular number of signal count and time. I want this function to wait for waitTimeoutMS and return if it receives a signal with specific data (instead of count). I tried bool QSignalSpy::wait(int timeout = 5000) but it return once it receives first signal.

    bool waitForSpyCalled(QSignalSpy& spy, int waitTimeoutMS, int expectCount = 1) {
      for (int delay = waitTimeoutMS; delay > 0 && spy.count() < expectCount;
           delay -= 200) {
        QTest::qWait(200);
      }
      return spy.count() >= expectCount;
    }
    
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean have QSignalSpy start spying only after some delay ?

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

      V 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Do you mean have QSignalSpy start spying only after some delay ?

        V Offline
        V Offline
        Venkateswaran
        wrote on last edited by Venkateswaran
        #3

        @SGaist Actually I want to look for a particular signal for period of time. Signal will emitted continuously from application.
        Like for example void signalEmitStatus(const EnumType& e);
        Now the enum type will be a list of application state like
        enum EnumType {
        Starting,
        Init,
        Init config,
        Checking peers,
        SUCCESS
        }

        App takes like 1000ms to reach "SUCCESS" state. So each state change gets emitted from signalEmitStatus, but some state will get skipped sometimes that's the reason I can't go with signal emit count. Either I have to collect signals for particular period of time and check the list of signals or need to spy for specific signal.

        I want to catch that SUCCESS state signal

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then I'd rather go with the inspection of the received value. That is more solid than relying on specific timing that might change with machine power.

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

          V 1 Reply Last reply
          0
          • SGaistS SGaist

            Then I'd rather go with the inspection of the received value. That is more solid than relying on specific timing that might change with machine power.

            V Offline
            V Offline
            Venkateswaran
            wrote on last edited by
            #5

            @SGaist you mean to inspect each signal emit until I find SUCCESS. Is it possible to collect signals for particular period of time ?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I think that you are looking for qWaitFor.

              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
              2

              • Login

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