PDA

View Full Version : QDialog - OnInitDialog equivalent



GimpMaster
31st March 2010, 19:32
Is there a signal that gets emitted when a QDialog has it's exec() called? Basically I want it so that when the dialog is displayed I want to initalize some settings that I don't necessarily want to do in the constructor of my subclassed QDialog.

In MFC a dialog would have it's OnInitDialog function called.

If there is no signal do I just override exec()......do my inital updates in there then call the base classes exec() ?

Thanks

squidge
31st March 2010, 19:38
Thats what I would do. Just note that exec() isn't virtual (Not really a problem in most cases, as you'll typically be passing around your subclassed type anyway).

wysota
31st March 2010, 20:12
You can reimplement showEvent() or use QMetaObject::invokeMethod() with QueuedConnection to execute a slot when the control returns to the event loop (so definitely after the constructor has already finished).

GimpMaster
31st March 2010, 20:15
Thank you both.