Tuesday 15 January 2013

c++ - Will QMessageBox block the running of the whole main thread in Qt? -



c++ - Will QMessageBox block the running of the whole main thread in Qt? -

i new qt

my situation is: reason, have emit heartbeat signal main thread, @ same time create qmessagebox window using:

reply = qmessagebox::question(this, tr("sure want quit?"), tr("sure quit?"), qmessagebox::yes|qmessagebox::no);

i want message box block user's input other windows, not want block heartbeat signal. how should this? or done default in qt?

qmessagebox::question internally executes event loop. continues running. don't need worried this.

however can unusual effects using such functions. e.g. if heartbeat open dialog dialog open if dialog open already. imagine have tcp/ip stack running. stack can go on happen... whereever qmessagebox::question() executed... in middle of function.

this why have policy in our company forbids utilize qmessagebox::question() (and similar) , phone call exec() on dialogs in our applications. creating modal dialogs on heap , utilize signals instead.

c++ qt qmessagebox

No comments:

Post a Comment