Unsolved QtFileDialog stocks after until subprocess finished
-
thx for telling me - I read this all day ... but still it did not work d for me ...
-
@ademmler
Glancing at sample code https://gist.github.com/ynonp/8148340, this should work, and give you the idea of what is needed. -
thx for pointing me to a working example.
-
@mrjj said in QtFileDialog stocks after until subprocess finished:
);
connect(&process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this,imagePath](){ ui->statusbar->showMessage("Subprocess ended.", 0
I used this and it works fine so far - the blocked dialog gets free ...
But I am wondering how I can pause the whole application until this thread is finished.Using process.waitForFinish() did not work here ...
What I want to achieve is - a free dialog, a progress bar telling me
that something is going on and at when all processes have end the image will be displayed and progress bar is stopped. -
@ademmler said in QtFileDialog stocks after until subprocess finished:
But I am wondering how I can pause the whole application until this thread is finished.
You dont pause a GUI app. That is simply wrong thinking.
Most of Qt classes work with signal and slot.So when you do something, you simply hook up to a signal and then when the signal comes, you
do what you need.So often you have to split the code in 2 parts.
The setup part
and the processing part where you react to the signal.You cannot pause an app. It will stop drawing and turns white etc.
and don't use waitForFinish as it hangs the app. really not a good idea in GUI apps. ever.
so just use signals and slots and the app will do nothing until some signal comes and then you
do what you need in the slot. -
Ok - thank your for clearing this - hence I need to get into slots and signals concept ...
-
@ademmler
Yes its a must use with Qt :)
At least when its a GUI app. -
Hello guys,
I have a conceptional question about Signals and slots which I could not find an answer.
-
Lets say I launch 2 processes one directly after the other.
-
Process A is much slower than process B.
-
I need to wait for Process A (and his slot subtasks) to be finished before I execute the "slot" of process B.
How can I achieve this?
-
-
@ademmler
Hi
I assume you mean 2 x QProcess ?You would simply hook up to A and when it says finished you
call the B slot.Or do you mean inside B, it needs to wait for A ?
If you just mean inside the app, then you can just use A signal and then
do what you need to do as B should be finished long time ago. -
@ademmler said in QtFileDialog stocks after until subprocess finished:
I need to wait for Process A (and his slot subtasks) to be finished before I execute the "slot" of process B.
Maybe you mean you could/should not start process B until process A is finished? Saying you don't want to execute a slot connected to process B until after those of process A seems strange.
-
To go deeper into it.
-
The reason is, that the time of the processes is always unknown and different. Hence I do not know how long each run of the app a process will take.
-
The only rule is A has to follow B
Isn't there any clear signal when a connect has taken place and when the related tasks are done?
Can I emit another Signal with in a "connection" ?
Regards Alexander
-
-
@ademmler said in QtFileDialog stocks after until subprocess finished:
Isn't there any clear signal when a connect has taken place and when the related tasks are done?
What "related tasks are done"? You have seen there is a
QProcess::finished
signal. If you want to only start B after A has finished, use that.