c++ - Windows message loop instead of QApplication::exec() / QApplication::processEvents() -


do miss qt functionality if substitute qapplication::exec() standard windows message loop implementation? should clarify mean:

the ususal “qt” way run event processing:

int main(int argc, char *argv[]) {  qapplication a(argc, argv);  window w;  w.show();  return a.exec(); } 

“windows” way run event processing:

#include <windows.h>  int main(int argc, char *argv[]) {  qapplication a(argc, argv);  window w;  w.show();   msg msg;  while(getmessage(&msg, 0, 0, 0)){     translatemessage(&msg);     dispatchmessage(&msg);  }   return msg.wparam; } 

the above demonstrates having external message loop respect qapplication instance, while qapplication instance doesn’t have own event loop @ all.

in other words, if have main.exe program (knowing nothing qt) message loop , .dll qt gui , qapplication instance inside, ok let external message loop main.exe handle events qt gui? in advance!

edit 1: i’ll answer myself in case it’s usefull somebody: have main .exe module written in c# under .net runs event loop processing, , have couple of .dlls written in qt/c++ have gui “inside” (and qapplication instance shared). qapplication::exec() never called events dispatched main .exe (.net) module’s event loop , all qt functionallity present( signals/slots, threads, etc.)

edit 2: worked qt 4.8.2 qt 5.1.0 things little bit different. you have call qapplication::processevents() once because performs initial initialization on first call( installs windowshook on getmessage or peekmessage ). , after whoever calls getmessage in application qt events processes , golden :)

the first thing comes mind calling slots across threads won't work because qt event loop executing calls.

but more important question probably: why want since in qeventdispatcher_win.cpp doing same thing?


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -