how to break while loop using some conditional check?
-
wrote on 16 Jul 2018, 06:40 last edited by VRonin
Hi
I am using SQLite database to fetch the data in Qt and then I am printing that data simultaneosly.
Kindly go through the process(e.g.
while(studentList.next()) { studentList("SELECT Name, address FROM class WHERE Roll No = some variable; Name=studentList.value(0).toString(); address=studentList.value(1).toString(); //******** simultaneously I am printing this data (in a string) through GPIO pins by setting them HIGH accordingly..... ****** // { ------ PRINTING MODULE ------ } }
During printing, GUI goes in a hang state .....
Now I want to break this printing in between as per my wish!
Any way to do it! -
Hi,
Depending on how you do that printing and more specifically the time it takes, you should rather offload the work to a secondary thread.
-
Hi,
Depending on how you do that printing and more specifically the time it takes, you should rather offload the work to a secondary thread.
If the time the printing module takes is rather short, it may already be enough to break the loop and put the loops body in a QTimers slot that you call regularly in short intervalls.
So in the time between the timers slots Qt has time to execute it's event loop.
-
Hi,
Depending on how you do that printing and more specifically the time it takes, you should rather offload the work to a secondary thread.
wrote on 16 Jul 2018, 09:25 last edited by SHUBHAM SINGH RAO@SGaist Right now I m in the learning stage of threading..so a bit difficult for me to apply it directly
Could u plz quote an example which can be referred? -
wrote on 16 Jul 2018, 09:55 last edited by
See "Staying Responsive During Intensive Processing" page 171 (189 of the pdf) of C++ GUI Programming with Qt 4
-
If the time the printing module takes is rather short, it may already be enough to break the loop and put the loops body in a QTimers slot that you call regularly in short intervalls.
So in the time between the timers slots Qt has time to execute it's event loop.
wrote on 23 Jul 2018, 06:21 last edited byThis post is deleted! -
Your loop blocks the event loop so it can't process anything.
6/7