c++ - Qt intercept Application::exec in the application class? -


is there way have function in application class (derived qapplication) called when qcoreapplication::exec() called? don't see signal or event generated prior message loop starting.

i have various components created depend on constructor application object. in turn, other components need created after components (as rely on them) -- these primary dialogs in application, has start them.

currently post queued signal application constructor, processed once event loop starts. i'm wondering if there clearer way intercept exec?

this old technique in gui applications might work you.

use qobject::starttimer(0) reimplement qobject::timerevent() have various components rely on constructed application object. doing so, various components rely on constructed application object created once event loop starts.

a little bit of explanation: qobject::starttimer(int ms) function runs timer in milliseconds fires every ms. if pass "0" argument, fires event loop starts. once fires, calls qobject::timerevent() in same class qobject::starttimer() called. make sure stop timer qobject::killtimer() inside reimplementation of qobject::timerevent() or else timer fire infinitely.

but @mat has point, because event loop has not started, not mean qcoreapplication not constructed. try , have @ this.

{   qapplication app(argc, argv); //this contructed qapplication instance   myclass *myobject = new myclass; //this relies on constructed qapplication instance    return app.exec(); //this starts event loop know. } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -