Skip to content

OverlayZStacking: The ultimate QQC2.Popup stacking manager

ivan tkachenko requested to merge work/ratijas/overlay-z-stacking into master

This utility component provides popups with sane defaults for stacking order, and ensures that children popups are never hidden behind parent. Say no more to random magic numbers like 999999 (is that enough btw?).

The attached property recognizes all four sub-types of QQC2.Popup, so it is not necessary to set layer on e.g. 3rd-party QQC2.Menu components.

Changing z index of a popup at runtime or even within aboutToShow handler doesn't seem to be supported, so OverlayZStacking defers emitting zChanged() signal until its attachee popup is closed.

Known limitations:

  • Parent popup is searched through a parent chain starting from Popup::parent item, but parentChanged signals of said hierarchy are not observed. This can be fixed, if needed, by storing list of connections and reconnecting all on any change.
  • QQC2 style implementations like qqc2-desktop-style and qqc2-breeze-style are expected to bind z index of relevant controls to Kirigami.OverlayZStacking.z property, otherwise attached objects won't be created.
  • Drawers go below "full screen" overlays, so if an overlay is supposed to fully block the scene then it should also be modal, or else user would be able to interact with a non-visible drawer.

Merge request reports