#include int main(int argc, char* argv[]) { QCoreApplication app(argc, argv); // just in case something is supposed to happen here... QThread t; QObject* worker = new QObject(); // similar to https://doc.qt.io/qt-5/qthread.html#details worker->moveToThread(&t); // incompatible with having a parent // let us attempt to simulate parent ownership with a QObject signal worker->connect(&t, &QObject::destroyed, &QObject::deleteLater); // leaks without warning because QCoreApplication::postEvent does not find threadData // a solution is suggested by some examples but https://doc.qt.io/qt-5/qthread.html#finished seems to be the only explicit documentation for it //worker->connect(&t, &QThread::finished , &QObject::deleteLater); t.start(); t.quit(); t.wait(); // to avoid a warning // just in case something is supposed to happen here... QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); return app.exec(); }