diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-23 13:46:18 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-23 13:46:18 +0200 |
commit | 1894da818656dd69a1309ecb7ce7ff816481ecfa (patch) | |
tree | bb58330182a9346f1e56e4a313ad665029861a17 /src/widgets/kernel/qwidget_qpa.cpp | |
parent | c5d1f239426b4cf9b3ddc0f34fd1514504dfb985 (diff) |
Added QWindow::setTransientParent().
Make the transient parent relationship explicit instead of having it
encoded through the window flags.
Diffstat (limited to 'src/widgets/kernel/qwidget_qpa.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget_qpa.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 02487679bf..b4ed00d36d 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -65,8 +65,12 @@ void q_createNativeChildrenAndSetParent(QWindow *parentWindow, const QWidget *pa if (childWidget->testAttribute(Qt::WA_NativeWindow)) { if (!childWidget->windowHandle()) childWidget->winId(); - if (childWidget->windowHandle()) - childWidget->windowHandle()->setParent(parentWindow); + if (childWidget->windowHandle()) { + if (childWidget->isTopLevel()) + childWidget->windowHandle()->setTransientParent(parentWindow); + else + childWidget->windowHandle()->setParent(parentWindow); + } } else { q_createNativeChildrenAndSetParent(parentWindow,childWidget); } @@ -103,8 +107,15 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO } if (QWidget *nativeParent = q->nativeParentWidget()) { - if (nativeParent->windowHandle()) - win->setParent(nativeParent->windowHandle()); + if (nativeParent->windowHandle()) { + if (flags & Qt::Window) { + win->setTransientParent(nativeParent->windowHandle()); + win->setParent(0); + } else { + win->setTransientParent(0); + win->setParent(nativeParent->windowHandle()); + } + } } win->create(); @@ -185,7 +196,18 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) q->windowHandle()->setWindowFlags(f); QWidget *parentWithWindow = newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0; - q->windowHandle()->setParent(parentWithWindow ? parentWithWindow->windowHandle() : 0); + if (parentWithWindow) { + if (f & Qt::Window) { + q->windowHandle()->setTransientParent(parentWithWindow->windowHandle()); + q->windowHandle()->setParent(0); + } else { + q->windowHandle()->setTransientParent(0); + q->windowHandle()->setParent(parentWithWindow->windowHandle()); + } + } else { + q->windowHandle()->setTransientParent(0); + q->windowHandle()->setParent(0); + } } } |