diff options
author | Andy Shaw <andy.shaw@digia.com> | 2013-01-06 21:45:56 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-10 07:09:56 +0100 |
commit | c40a1f6b2fb0d950bfe79ad66e36930f0282b1eb (patch) | |
tree | 8f83d3cb976469feaca16e571b88fa537fa11be5 /src/widgets/dialogs/qdialog.cpp | |
parent | 724cb5d30fda4b62cbc3fa5ab37da1b9c43dad6a (diff) |
Use pos() if the widget is a child of a native window
If the widget is embedded in a native window then pos() should be used
instead of mapToGlobal() so that the right position is used. This was
reproduced with the qtwinmigrate solution as the dialogs were not
centered correctly.
Change-Id: I2ce7771f8c1a73aa74ab11faf4f9c57b922eefab
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/widgets/dialogs/qdialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 290f0a7f65..a765e8b7ef 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -827,9 +827,12 @@ void QDialog::adjustPosition(QWidget* w) if (w) { - // Use mapToGlobal rather than geometry() in case w might - // be embedded in another application - QPoint pp = w->mapToGlobal(QPoint(0,0)); + // Use pos() if the widget is embedded into a native window + QPoint pp; + if (w->windowHandle() && w->windowHandle()->property("_q_embedded_native_parent_handle").value<WId>()) + pp = w->pos(); + else + pp = w->mapToGlobal(QPoint(0,0)); p = QPoint(pp.x() + w->width()/2, pp.y() + w->height()/ 2); } else { |