Unsolved optimizing gui and parralel processing?
-
@aravmadd said in optimizing gui and parralel processing?:
proc->waitForFinished();
This will block your GUI until process finishes. Don't do this!
Connect a slot to https://doc.qt.io/qt-5/qprocess.html#finished signal instead. And move this codeQString result = proc->readAllStandardOutput(); ui->plainTextEdit->appendPlainText(result);
to that slot...
-
@aravmadd said in optimizing gui and parralel processing?:
Is there a way to run all this process separately? For Example even though it takes time it should be like unable to respond install we can be able to perform other functionality by using some parrale processing/threads. I am not sure how to do this!
proc->waitForFinished()
The whole point is not to use
QProcess::waitForFinished
. That is what blocks the UI. UseQProcess
signals (likefinished
) to update the UI. Then the processes run asynchronously to your application. -
@jsulm said in optimizing gui and parralel processing?:
QString result = proc->readAllStandardOutput();
ui->plainTextEdit->appendPlainText(result);HI Thanks for replying and giving your valuable time and suggestions. However i didnt get/ understood to do what you have said .
I understood like this
connect(proc, SIGNAL(finished(int , QProcess::ExitStatus )),
this, SLOT(i am not sure which slot sorry for my stupid questiom)); -
@aravmadd said in optimizing gui and parralel processing?:
i am not sure which slot sorry for my stupid questiom
Well, your own slot inside Widget class. Simply add a slot in Widget with same parameters as the signal.
-
@jsulm Thanks i will give a try. Will update in forum if i can succefully implement!! Many Thanks :-)
-
@aravmadd
Hi
Just so im sure i understand.
You talk about doing heavy calc in app, calc, but you seem to show code running an extern process (another .exe)If you mean to run some other app, all is fine but i just have to ask :)
-
@mrjj HI! YOU are right i am also running other executable after taking all other inputs from gui. For this i am using process.
I am also doing some heavy math calc for example using EIgen Library and other stuff to do some moderate math. But for doing this thing it is taking sometime, and during this time my gui gets blocked because of things which already mentioned by @jsulm and @JonB
-
@sm2770s
Well what we and you have been talking about here isQProcess
, which you will solve by using signals and slots. If you have heavy Eigen calculations you need to call in the Qt process then you will have to use separate threads if you need to keep the UI responsive. -
@JonB said in optimizing gui and parralel processing?:
which you will solve by using signals and slots. If you have heavy Eigen calculations you need to call in the Qt process then you will have to use separate threads if you need to keep the UI responsive.
HI Jon! As of now i am planning to move my calculations into executable so it can be easy and my executable does that math stuff and i think that would be optimistic way.
But what i would like to try for now is each button/checkbox or lineedit should run without making my gui unresponsive by using different process. For time being i am trying to ignore heavy calculations and give a try.
Can you give some suggestion if this approach seems legit?
-
@sm2770s said in optimizing gui and parralel processing?:
@JonB said in optimizing gui and parralel processing?:
which you will solve by using signals and slots. If you have heavy Eigen calculations you need to call in the Qt process then you will have to use separate threads if you need to keep the UI responsive.
HI Jon! As of now i am planning to move my calculations into executable so it can be easy and my executable does that math stuff and i think that would be optimistic way.
But what i would like to try for now is each button/checkbox or lineedit should run without making my gui unresponsive by using different process. For time being i am trying to ignore heavy calculations and give a try.
Can you give some suggestion if this approach seems legit?
I may be reading this discussion wrong, but...
If there is a time consuming task, it does not matter what approach you take - your GUI has to wait until the task returns valid data.
Perhaps "blocking (GUI) " is incorrect term to use.
Not sure if I agree to try to fool the user that the code is magically working "faster than a speeding bullet".
My approach - KISS - I preferQConnectivitywhoops - wrong word - QtConcurrent and I use it to let the user know it is actually taking time to finish the task.
Just my opinion. -
@sm2770s
So long as you do your computations out-of-process viaQProcess::start()
your UI will not become unresponsive, provided you use the signals/slots and notQProcess::waitFor...()
. -
@AnneRanch I think blocking GUI is wrong word. I mean what you understood is right!
-
@JonB will give a look into what you mentioned . Thanks a lot again :-)
-
@AnneRanch Throw any time-consuming job into a thread or a qprocess and add a progress bar to show something is in progress. Keep GUI idle.