Originally Posted by
soul_rebel
How do I actually implement this?
If you want to use the event loop, your CLI application must be event-driven.
int main( int argc, char **argv )
{
MyApp realApp( argc, argv );
// schedule a call to "run"
QMetaObject::invokeMethod( & realApp,
"run", Qt
::QueuedConnection );
// if you prefer a shorter, but more cryptic way, use:
// QTimer::singleShot( 0, & realApp, SLOT( run() ) );
return app.exec();
}
int main( int argc, char **argv )
{
QCoreApplication app( argc, argv );
MyApp realApp( argc, argv );
// schedule a call to "run"
QMetaObject::invokeMethod( & realApp, "run", Qt::QueuedConnection );
// if you prefer a shorter, but more cryptic way, use:
// QTimer::singleShot( 0, & realApp, SLOT( run() ) );
return app.exec();
}
To copy to clipboard, switch view to plain text mode
(of course MyApp::run() has to be a slot).
Bookmarks