Why is a QProgressDialog doesn't get updated after executing a QProcess?
I am using a QProgressDialog to show the status of a long running operation, which includes a step of running an external executable. I run the external e开发者_Python百科xecutable using the QProcess::execute() method. QprogressDialog works fine updating the label text till it reaches the QProcess::execute() method, after which it doesn't update the state.
How to update the state after running the executable.
QProcess::execute()
is a blocking method: it will block its calling thread until the spawned process will terminate. It you call this method from the main thread, UI events will not be handled until the method will return.
To get around this you can create an instance of QProcess
(rather than using its static methods) and then create a slot that continues the part of the operation that happens after the external process finishes running, and connect it to the QProcess::finished(int, QProcess::ExitStatus)
signal.
精彩评论