Skip to content

[qtquickdialogwrapper] Fix finding parent window

Nicolas Fella requested to merge work/fixparentsforrealmaybe into master

For various reasons we want to set a transientParent on the dialog window.

Currently we take QGuiApplication::focusWindow as first guess, which works okay, sometimes.

However, QGuiApplication::focusWindow can be a menu/popup, in which case we can't use it as a parent window.

Therefore the current code walks up the focus window's parents until it finds a "proper" window. It does that based on the objectName, which is brittle since it can be set to anything. Also we are operating on a window object here, not actually a QMenu, so comparing the class name to QMenu wouldn't work.

Checking whether the window is a popup seems to produce more reliable results, so do that.

Ideally we wouldn't have this heuristic at all and instead explicitly pass in a parent from the outside, but that would require changing consumers

Merge request reports