diff --git a/src/declarativeimports/plasmacomponents/qmenu.cpp b/src/declarativeimports/plasmacomponents/qmenu.cpp --- a/src/declarativeimports/plasmacomponents/qmenu.cpp +++ b/src/declarativeimports/plasmacomponents/qmenu.cpp @@ -108,6 +108,13 @@ m_visualParent = parent; emit visualParentChanged(); + + QQuickItem *item = qobject_cast(m_visualParent.data()); + if (item) { + //create the QWindow + m_menu->winId(); + m_menu->windowHandle()->setTransientParent(item->window()); + } } QWindow *QMenuProxy::transientParent() @@ -290,6 +297,12 @@ m_menu->addSection(item->text()); } else { m_menu->addAction(item->action()); + if (item->action()->menu()) { + //This ensures existence of the QWindow + m_menu->winId(); + item->action()->menu()->winId(); + item->action()->menu()->windowHandle()->setTransientParent(m_menu->windowHandle()); + } } } @@ -306,6 +319,11 @@ parentItem = qobject_cast(m_visualParent.data()); } else { parentItem = qobject_cast(parent()); + if (parentItem) { + //create the QWindow + m_menu->winId(); + m_menu->windowHandle()->setTransientParent(parentItem->window()); + } } if (!parentItem) {