Keep widget on top in Qt

2019-06-26 16:03发布

I'm creating an application which has a "floating" widget which can be dragged around inside the application window. But it starts up, or tends to go behind other widgets sometimes. Is there any way to make sure that the widget in my application stays on top of all other widgets whenever it is made visible?

Thanks.

标签: qt qt4 widget
2条回答
Rolldiameter
2楼-- · 2019-06-26 16:36

You can call raise() on your widget to make it appear in front of all other child widgets of the parent it is in. If I read your question correctly, this is the behavior you want. However, any child you create and add to a parent widget will automatically be placed above that widget, so you may need to reraise the widget after additions, or you may want to consider an alternate way of managing the parent/child relationship.

查看更多
贪生不怕死
3楼-- · 2019-06-26 16:44

Use the flag Qt::WindowStaysOnTopHint for your QWidget. This will force your widget to stay on top of all other windows

查看更多
登录 后发表回答