From 2d0957d4b84ca3b07a62ce5c87e0f656dbe690de Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 10 Feb 2015 17:43:03 +0300 Subject: [PATCH 1/1] Fix centering dialogs QDialog::setVisible() tries to adjusts the dialog position, but it's not really possible if the dialog size is not defined yet. Besides, if the dialog window is not created, QWidget::move() will not really move it and will set WA_PendingMoveEvent flag. And QWidget::setVisible() also will not change the position, because we reset WA_Moved flag. Thus it may break adjusting the position in QDialog::showEvent(). So adjust the position only in QDialog::showEvent(). Task-number: QTBUG-36185 Task-number: QTBUG-39259 Task-number: QTBUG-41844 Change-Id: I015a19f2e533f68178f4ee7519b17f5e9b5def7b Reviewed-by: Timur Pocheptsov --- src/widgets/dialogs/qdialog.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 6de3ff8c157c7e97fa334c07d5adbd4c64d948a7..22025378afb75339c8ae298720089e40ce5682b8 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -717,13 +717,6 @@ void QDialog::setVisible(bool visible) if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) return; - if (!testAttribute(Qt::WA_Moved)) { - Qt::WindowStates state = windowState(); - adjustPosition(parentWidget()); - setAttribute(Qt::WA_Moved, false); // not really an explicit position - if (state != windowState()) - setWindowState(state); - } QWidget::setVisible(visible); showExtension(d->doShowExtension); QWidget *fw = window()->focusWidget(); -- 2.4.2