CoderMan
23rd February 2012, 20:45
I have several dialogs subclassed from QDialog and all are created and shown the same way:
SomeDialog dlg(this);
dlg.exec();
However, only one of the dialogs behaved in the way I expected based on the reference: "A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself)." The others appeared in more or less random locations. After some effort I found out the proximate cause: the randomly appearing ones overrode QDialog::showEvent(QShowEvent* event) while the properly appearing dialog did not.
I worked around this by deleting the showEvents from the offending classes, but supposing that I do need to do something in that function, how do I replicate the desired default behaviour regarding positioning?
SomeDialog dlg(this);
dlg.exec();
However, only one of the dialogs behaved in the way I expected based on the reference: "A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself)." The others appeared in more or less random locations. After some effort I found out the proximate cause: the randomly appearing ones overrode QDialog::showEvent(QShowEvent* event) while the properly appearing dialog did not.
I worked around this by deleting the showEvents from the offending classes, but supposing that I do need to do something in that function, how do I replicate the desired default behaviour regarding positioning?