While developing Qt UIs, I often want to display a notification or other display tool on top of an existing UI.
However, I have only discovered two ways of doing this, but neither completely solves the problem.
Option 1
Make the notification widget a sibling of the displayed widgets, but don't add it to any layout and raise it above the other one.
Problem: The widget can't be in a layout, and so you have to manually size it to fit it's contents, and you have to move it to the correct position whenever the parent window is resized.
Option 2
Add the widget to the layout right alongside the displayed widgets.
Problem: Since the widget is part of the layout, it moves the other displayed widgets around when it is visible, rather than on top of them.
Example - here the notification pushes the "v0.3b" label upwards rather than appearing on top of it. On the upside, since it is part of the layout with the spacer on its left, it is sized appropriately to its contents.
Solution
Is there something like a QStackedWidget
that displays multiple pages at once, with the empty area showing the widgets beneath? Is there another option for this kind of UI feature?