Keep widget on top in Qt

浪子不回头ぞ 提交于 2019-12-10 18:14:27

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/2463125/keep-widget-on-top-in-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!