0

I have a gui class and another class named guiThread. The gui class starts guiThread as a thread that communicates with gui with the help of signals and slots.
I have a slot in guiThread named doAction() and I have a signal which is send from gui class to this slot.
So what I want to do in guiThread is that I want to do a while loop that waits until the signal is sent from gui to doAction() slot and when it recieved the signal, the slot does some calculations.
I dont know how to do this while loop and I dont even know if what I want is possible. I would be appreciate it if somebody could help me.

  • 1
    What is the purpose of that while loop? Just idly waiting? I think the concept of signal/slot does exactly what you want to do - there is no need for that while loop. Maybe I misunderstand what you are trying to do...? – Paraboloid87 Mar 18 '20 at 10:16

1 Answers1

0

You need to initialize a private boolean block=true, then you wait for the signal by while(block);. Whenever you receive the signal, you do your calculations in the corresponding slot, and update block=false at the end of it. Thus, when the code returns to the while, it will pass to continue processing.

Mohammed Deifallah
  • 1,290
  • 1
  • 10
  • 25