I’m doing my first project in Qt and I have the problem. I know that there are many similar requests on the SO nad Qt forum, but no one answered my question.
I would like to stop the program execution and wait for the click of the button. More or less the situation:
slot1() {
for (int i=0; i<10; i++) {
/*
* some code
*/
// STOP EXECUTION - WAITING FOR THE BUTTON PRESSED
/*
* the rest of code
*/
}
}
I know that this is contrary to event-driven programming, but the requirements of the project (task of course on studies) require that way. It is very important for me, so please – give possible solutions :)
Try running nested event loop. But other buttons would still be clickable.
QEventLoop loop;
QObject::connect(btn, SIGNAL(clicked()), &loop, SLOT(quit()));
loop.exec();