I have a program that has a Worker
class and this class has 3 QProcess
es.
Each process will require a QDate
as an argument.
I want
Your program freezes because it is busy all the time with waiting on QProcess
to be finished, i.e. while(1)
. So, you do not return to the main event loop before all your dates are processed. If you wait long enough, your program will unfreeze.
Different solutions exist:
Use the finished
event to start processing a new date (until the list is empty), i.e. remove the infinite/waiting loop while(1)
.
Perform Worker::run
in a separate thread.
Call QCoreApplication::processEvents to process the pending events, for example when has_available
is false.
Note that I prefer the first solution as Qt is an event driven system.