how to break while loop using some conditional check?
-
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.
-
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.
-
See "Staying Responsive During Intensive Processing" page 171 (189 of the pdf) of C++ GUI Programming with Qt 4
-
This post is deleted!
-
Your loop blocks the event loop so it can't process anything.