Transient parent for QtWidgets popup menus
Elvis Angelaccio
elvis.angelaccio at kde.org
Sun May 28 08:12:53 UTC 2017
Hi all,
as you may know in Wayland popup menus are wrongly positioned if they don't
have
a transient parent set on their window.
For QtWidget applications the fix itself is rather easy (at least in the
simplest case):
someMenu->createWinId(); // someMenu is a QMenu
someMenu->windowHandle()->setTransientParent(someWidget->nativeParentWidget()->windowHandle());
But I see a number of problems:
1. Popup menus are literally everywhere in QtWidgets applications, so we
need to apply the fix in a lot of places.
2. Popup menus are often hidden, so we may easily forget to fix some of
them.
3. We don't control 3d-party Qt apps, so we can't fix them if they are
broken.
4. The fix involves createWindId() which is marked as "internal", it feels
wrong to use it everywhere imho.
Shouldn't we fix this issue in upstream QMenu instead?
Basically if we have existing code that does:
menu = new QMenu(someParent);
then the QMenu constructor could do:
createWinId();
windowHandle()->setTransientParent(parent()->nativeParentWidget()->windowHandle());
Does it makes sense? Would it work?
If it does, we would fix most of the existing popup menus for free...
Cheers,
Elvis
More information about the Plasma-devel
mailing list