c++ - How to befriend QEventLoop and winapi event loop -


i have myapp class winapi event loop in it

class myapp : public qobject {     q_object public:     int winapi exec() {         msg msg;         int nretval;         while ((nretval = ::getmessage(&msg, nullptr, 0, 0)) != 0 && nretval != -1) {             ::translatemessage(&msg);             ::dispatchmessage(&msg);         }         return msg.wparam;     } }; 

when start program, qobject's events won't process (can't invoke slot , hence send signals).
somewhere on internet found kind of solution - create qapplication object, somehow "hooks up" winapi message loop , worked:

int main(int _argc, char* _argv[]) {     qapplication qa(_argc,_argv);     unreferenced_parameter(qa);      myapp mapp();     return mapp.exec(); } 

but seems me design fragile , hack. , don't i'm using undocumented feature , never call qapplication.exec() method.
can tell me how right way? namely, want call 1 exec method (i guess 1 of qapplication, should put winapi loop?)
help


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -