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:
parent
724cb5d30f
commit
c40a1f6b2f
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user