Back in Dos, when I had a long time consuming function (depending on the user
input data) and I wanted to give the user the change to abort that function so
he could alter the input data without having to wait for the end of calculation,
I would do something like this:
for (i=0;i<Lots_of_calculation && !kbhit() ;i++)
{
....
lots of calculation;
blablabla...;
more calculation;
.....
}
for (i=0;i<Lots_of_calculation && !kbhit() ;i++)
{
....
lots of calculation;
blablabla...;
more calculation;
.....
}
To copy to clipboard, switch view to plain text mode
the kbhit() would terminate the for, if the user pressed a key.
This did not work in the actual Qt, so I tried something like:
for (i=0;i<Lots_of_calculation && flagAbortFunction ;i++)
{
....
lots of calculation;
blablabla...
more calculation;
.....
}
void someClass
::keyPressEvent(QKeyEvent *event
) {
flagAbortFunction = false;
QMessageBox(this,
"title",
"Show something to see if the function ended and ask user input data that process more quicly");
}
for (i=0;i<Lots_of_calculation && flagAbortFunction ;i++)
{
....
lots of calculation;
blablabla...
more calculation;
.....
}
void someClass::keyPressEvent(QKeyEvent *event)
{
flagAbortFunction = false;
QMessageBox(this,"title","Show something to see if the function ended and
ask user input data that process more quicly");
}
To copy to clipboard, switch view to plain text mode
this code waits about one minute or so after the keypressed , and only then display
the message box, so it's also not working, because doenst end the 'for'. It seems that
the event keypressed is only processed after the function terminate, because the function
displays all the data, without signs of being interrupted.
Any ideas how how can I achieve my goal ???????
Bookmarks