I created a simple program that reproduces the problem. When I lock my phone, or if I switch to another application on my Android phone, the workflow will continue to print, but the event loop will stop . When I return to my application, the loop cycle resumes.
If I replace QGuiApplication with QCoreApplication, the problem goes away. If I compile Qt 5.2 instead of Qt 5.3, the problem goes away. Qt 5.4 has the same problem as Qt 5.3.
static int count = 0; void workerThread() { while (1) { qDebug("Worker thread %d", count++); sleep(1); } } void MyObject::step() { qDebug("Event loop %d", count++); } int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); MyObject w; QTimer timer; QObject::connect(&timer, SIGNAL(timeout()), &w, SLOT(step())); timer.start(1000); QtConcurrent::run(workerThread); return a.exec(); }
How to prevent QGuiApplication from stopping the event loop when an application loses focus? I need my event handling application, even if it is not in the foreground.
sashoalm
source share