Merge pull request #644 from DelphiGit/master

New approach to make EditDialog appear centered over the main window
This commit is contained in:
Justin Clift
2016-07-12 18:58:38 +01:00
committed by GitHub

View File

@@ -54,12 +54,11 @@ void EditDialog::closeEvent(QCloseEvent*)
void EditDialog::showEvent(QShowEvent*)
{
// Whenever the dialog is shown, position it at the center of the parent dialog
QPoint center = mapToGlobal(rect().center());
QMainWindow* parentDialog = qobject_cast<QMainWindow*>(parent());
if(parentDialog)
{
QPoint parentCenter = parentDialog->window()->mapToGlobal(parentDialog->window()->rect().center());
move(parentCenter - center);
move(parentDialog->x() + parentDialog->width() / 2 - width() / 2,
parentDialog->y() + parentDialog->height() / 2 - height() / 2);
}
}