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>
This commit is contained in:
Andy Shaw 2013-01-06 21:45:56 +01:00 committed by The Qt Project
parent 724cb5d30f
commit c40a1f6b2f

View File

@ -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 {