Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
QThreadPool lingers till the end of the app, for good or bad
#include <QtCore>
class TurtleRunnable : public QRunnable
{
void run() override {
for (int i = 0; i < 15; ++i) {
qDebug("Tick %i", i);
QThread::sleep(1);
}
}
};
int main(int argc, char *argv[])
{
QCoreApplication application(argc, argv);
QThreadPool::globalInstance()->start(new TurtleRunnable);
QTimer::singleShot(3000, [&application](){
qDebug("I'd like to quit now");
application.quit();
});
application.exec();
qDebug("And done");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.