From c40a1f6b2fb0d950bfe79ad66e36930f0282b1eb Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Sun, 6 Jan 2013 21:45:56 +0100 Subject: 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 --- src/widgets/dialogs/qdialog.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/widgets/dialogs/qdialog.cpp') 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()) + pp = w->pos(); + else + pp = w->mapToGlobal(QPoint(0,0)); p = QPoint(pp.x() + w->width()/2, pp.y() + w->height()/ 2); } else { -- cgit v1.2.3