简体   繁体   中英

How would I go about making a overlay widget

How would I go about making a overlay widget with qt? 例

例子2

I've considered using a QPaintEvent or a QGraphicsScene, but I want to be able to add widgets and for the widget to not occupy space in a layout, causing other widgets to shift when the popup appears.

I believe the best solution is to parent the so called overlay widget to the window or even have the overlay widget be in its own window.

The first solution might be easier to do, but the overlay widget is bound to the inside of the window.

If you go with the second solution, you will have to play with the windows flags to make it borderless.

In both cases, you may have to use the raise() function to make sure your overlay widget is on top.

Discussing "using a QPaintEvent or a QGraphicsScene" is off-topic. How you draw the widget does not impact how the widget will interact with the widget stack.

If you want an example, you can take a look at the code of QCompleter which does something similar. In particular look for QCompleter::setPopup() and QCompleterPrivate::showPopup() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM