Think of the any Qt program as a cooperative-multitasking system. Graphics and events in general are handled by the main loop. You don't want to stay long in any slot, because the library won't process signals (say button clicks, repaints, but also other stuff) in the mean time.
If you want to do some heavy processing, or anything that needs to wait for resources while the rest of the program is chugging along, use a QThread
.
Another option is to force the event processing with qApp.processEvents()
(you can find qApp
in QtGui
), just before your sleep(5)
(or whatever code you're going to put in place of it).
Edit: Now, keep in mind that forcing the event processing will just show the QDialog
you're trying to popup. You can't do anything with it (remember, no event processing) without calling again qApp.processEvents()
or returning from the slot.