Set correct transient parent in q_createNativeChildrenAndSetParent().
Fix warning: void QWindow::setTransientParent(QWindow*) ... must be a top level window. which occurred for example when parenting a QMenu onto a native child widget. Task-number: QTBUG-41898 Change-Id: Icc25fb2108bd68b2d9c0e551949b90fc7a82d358 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>bb10
parent
520b10be4c
commit
6c7a348cf8
|
|
@ -1362,11 +1362,11 @@ void q_createNativeChildrenAndSetParent(const QWidget *parentWidget)
|
|||
if (!childWidget->internalWinId())
|
||||
childWidget->winId();
|
||||
if (childWidget->windowHandle()) {
|
||||
QWindow *parentWindow = childWidget->nativeParentWidget()->windowHandle();
|
||||
if (childWidget->isWindow())
|
||||
childWidget->windowHandle()->setTransientParent(parentWindow);
|
||||
else
|
||||
childWidget->windowHandle()->setParent(parentWindow);
|
||||
if (childWidget->isWindow()) {
|
||||
childWidget->windowHandle()->setTransientParent(parentWidget->window()->windowHandle());
|
||||
} else {
|
||||
childWidget->windowHandle()->setParent(childWidget->nativeParentWidget()->windowHandle());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
q_createNativeChildrenAndSetParent(childWidget);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
#include <qmainwindow.h>
|
||||
#include <qdockwidget.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <QtGui/qpaintengine.h>
|
||||
#include <QtGui/qbackingstore.h>
|
||||
#include <QtGui/qguiapplication.h>
|
||||
|
|
@ -268,6 +269,7 @@ private slots:
|
|||
void winIdChangeEvent();
|
||||
void persistentWinId();
|
||||
void showNativeChild();
|
||||
void transientParent();
|
||||
void qobject_castInDestroyedSlot();
|
||||
|
||||
void showHideEvent_data();
|
||||
|
|
@ -3992,6 +3994,21 @@ void tst_QWidget::persistentWinId()
|
|||
QCOMPARE(w3->winId(), winId3);
|
||||
}
|
||||
|
||||
void tst_QWidget::transientParent()
|
||||
{
|
||||
QWidget topLevel;
|
||||
topLevel.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize));
|
||||
topLevel.setWindowTitle(__FUNCTION__);
|
||||
QWidget *child = new QWidget(&topLevel);
|
||||
QMenu *menu = new QMenu(child); // QTBUG-41898: Use top level as transient parent for native widgets as well.
|
||||
QToolButton *toolButton = new QToolButton(child);
|
||||
toolButton->setMenu(menu);
|
||||
toolButton->winId();
|
||||
topLevel.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
|
||||
QCOMPARE(menu->windowHandle()->transientParent(), topLevel.windowHandle());
|
||||
}
|
||||
|
||||
void tst_QWidget::showNativeChild()
|
||||
{
|
||||
QWidget topLevel;
|
||||
|
|
|
|||
Loading…
Reference in New Issue