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. C# waitone-like functionality?
Forum Updated to NodeBB v4.3 + New Features

C# waitone-like functionality?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 473 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.
  • I Offline
    I Offline
    IknowQT
    wrote on 3 May 2022, 08:26 last edited by
    #1

    The function I want to do may not be exactly the same as waitone, but for example it repeats some action in a for loop.
    The code inside the for loop repeats continuously, but I want to wait until a specific signal is received.

    Is there a way to stop repeating until a specific signal is received and resume when the signal is received?

    J 1 Reply Last reply 3 May 2022, 08:41
    0
    • I IknowQT
      3 May 2022, 08:50
      	for (int nCnt = 1; nCnt <= m_pDataModel->rowCount(); nCnt++)
      		{
      			// [ 샘플을 넣으세요 Msg 출력]
      			{
      				wMessageBox msg(QString::fromLocal8Bit("샘플을 삽입하십시오"), this);
      			}
      
      			cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve);
      
      			if (data)
      			{
      				qDebug() << "data1 : " << data;
      				float fa = data->ABS;
      				float ft = data->Trans;
      			}
      			
      		}
      		break;
      

      cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve) is a function that tells the measurement start from tcp.

      After clicking on the message, it sends a start signal and when a packet indicating that the action is over is received, it tries to process the data.
      You have to process this as iteratively as a loop. And since there is time to measure, the next loop can be performed only when the measurement complete signal is received.

      Can I use it as a qtimer in this case as well?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 3 May 2022, 08:53 last edited by
      #4

      @IknowQT said in C# waitone-like functionality?:

      You have to process this as iteratively as a loop

      No, you don't.
      Implement it properly using signals/slots, then you do not need such a loop.

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

      I 1 Reply Last reply 4 May 2022, 00:15
      0
      • I IknowQT
        3 May 2022, 08:26

        The function I want to do may not be exactly the same as waitone, but for example it repeats some action in a for loop.
        The code inside the for loop repeats continuously, but I want to wait until a specific signal is received.

        Is there a way to stop repeating until a specific signal is received and resume when the signal is received?

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 3 May 2022, 08:41 last edited by
        #2

        @IknowQT You should not have any long lasting loops when using event driven frameworks like Qt! Else signals/slots will not work!
        What you can do: use a timer, in the slot connected to the timout signal you put the code you currently have in that loop. In the slot you connect to the signal you described you set a flag variable which you then check in the timout slot to decide whether you should execute the code or not.

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

        1 Reply Last reply
        0
        • I Offline
          I Offline
          IknowQT
          wrote on 3 May 2022, 08:50 last edited by
          #3
          	for (int nCnt = 1; nCnt <= m_pDataModel->rowCount(); nCnt++)
          		{
          			// [ 샘플을 넣으세요 Msg 출력]
          			{
          				wMessageBox msg(QString::fromLocal8Bit("샘플을 삽입하십시오"), this);
          			}
          
          			cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve);
          
          			if (data)
          			{
          				qDebug() << "data1 : " << data;
          				float fa = data->ABS;
          				float ft = data->Trans;
          			}
          			
          		}
          		break;
          

          cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve) is a function that tells the measurement start from tcp.

          After clicking on the message, it sends a start signal and when a packet indicating that the action is over is received, it tries to process the data.
          You have to process this as iteratively as a loop. And since there is time to measure, the next loop can be performed only when the measurement complete signal is received.

          Can I use it as a qtimer in this case as well?

          J 1 Reply Last reply 3 May 2022, 08:53
          0
          • I IknowQT
            3 May 2022, 08:50
            	for (int nCnt = 1; nCnt <= m_pDataModel->rowCount(); nCnt++)
            		{
            			// [ 샘플을 넣으세요 Msg 출력]
            			{
            				wMessageBox msg(QString::fromLocal8Bit("샘플을 삽입하십시오"), this);
            			}
            
            			cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve);
            
            			if (data)
            			{
            				qDebug() << "data1 : " << data;
            				float fa = data->ABS;
            				float ft = data->Trans;
            			}
            			
            		}
            		break;
            

            cGlobalParam::SendMeasureStart(ModeTypes::StandardCurve) is a function that tells the measurement start from tcp.

            After clicking on the message, it sends a start signal and when a packet indicating that the action is over is received, it tries to process the data.
            You have to process this as iteratively as a loop. And since there is time to measure, the next loop can be performed only when the measurement complete signal is received.

            Can I use it as a qtimer in this case as well?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 3 May 2022, 08:53 last edited by
            #4

            @IknowQT said in C# waitone-like functionality?:

            You have to process this as iteratively as a loop

            No, you don't.
            Implement it properly using signals/slots, then you do not need such a loop.

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

            I 1 Reply Last reply 4 May 2022, 00:15
            0
            • J jsulm
              3 May 2022, 08:53

              @IknowQT said in C# waitone-like functionality?:

              You have to process this as iteratively as a loop

              No, you don't.
              Implement it properly using signals/slots, then you do not need such a loop.

              I Offline
              I Offline
              IknowQT
              wrote on 4 May 2022, 00:15 last edited by
              #5

              @jsulm

              Thank you for your reply. Let's try it.

              1 Reply Last reply
              0

              1/5

              3 May 2022, 08:26

              • Login

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