void EditDialog::showEvent(QShowEvent*) { // Whenever the dialog is shown, position it at the center of the parent dialog QPoint center = mapToGlobal(rect().center()); QDialog* parentDialog = qobject_cast<QDialog*>(parent()); if(parentDialog) { QPoint parentCenter = parentDialog->window()->mapToGlobal(parentDialog->window()->rect().center()); move(parentCenter - center); } }