How keep a QWidget always on top?

蓝咒 提交于 2019-12-08 16:55:27

问题


I have two buttons on my QMainWindow. One to btnShowKb and another btnHideKb. When i press btnShowKb it shows an QWidget. I want this QWidget always to be on top of all windows till I press btnHideKb. When its on top, I want both QWidget and QMainWidget be activated.

Can anybody suggest on this?


回答1:


Setting the setWindowFlags() with Qt::WindowStaysOnTopHint is meant to help.

https://doc.qt.io/archives/qt-4.7/qt.html#WindowType-enum

https://doc.qt.io/archives/qt-4.7/widgets-windowflags.html




回答2:


Nokia was so yesterday...

New link: http://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html

and the line of code you might be looking for:

mainMenu->setWindowFlags(Qt::WindowStaysOnTopHint);


来源:https://stackoverflow.com/questions/4952277/how-keep-a-qwidget-always-on-top

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