A new approach to make the EditDialog appear centered over the main window.

See issue #633 for details.
This commit is contained in:
DelphiGit
2016-07-09 22:32:13 +02:00
parent 3b3d4b4c91
commit b72bcd7a88

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);
}
}