summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorMorteza Jamshidi <morteza.jamshidi@qt.io>2024-09-23 12:57:45 +0200
committerMorteza Jamshidi <morteza.jamshidi@qt.io>2025-01-22 12:57:18 +0100
commitd4ccceabf44ef577d0f5f12bf0c7e109ea4f3fbe (patch)
tree4abd8e902f0a84fe5c76af7966cdc3f703f392e7 /src/widgets/kernel/qwidget.cpp
parent9261b68395df75dbb01539c547832d9cc35521d9 (diff)
Use old position to set window position after recreation
Like window state and visibility, the window position should also remain the same after the window is recreated. Fixes: QTBUG-128790 Change-Id: Iad8599da7ef83eff6a93f7f071e6b452491a0d87 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 6131491aaa1..c0896e87d99 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -10908,10 +10908,12 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
<< "to support" << surfaceType;
const auto windowStateBeforeDestroy = newParentWithWindow->windowState();
const auto visibilityBeforeDestroy = newParentWithWindow->isVisible();
+ const auto positionBeforeDestroy = newParentWithWindow->pos();
newParentWithWindow->destroy();
newParentWithWindow->create();
Q_ASSERT(newParentWithWindow->windowHandle());
newParentWithWindow->windowHandle()->setWindowStates(windowStateBeforeDestroy);
+ newParentWithWindow->move(positionBeforeDestroy);
QWidgetPrivate::get(newParentWithWindow)->setVisible(visibilityBeforeDestroy);
} else if (auto *backingStore = newParentWithWindow->backingStore()) {
// If we don't recreate we still need to make sure the native parent