Sulla
Sulla

Reputation: 8019

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 executable 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.

Upvotes: 0

Views: 1082

Answers (1)

IgKh
IgKh

Reputation: 945

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.

Upvotes: 2

Related Questions