How to keep QWidget always on top?

I have two buttons on my QMainWindow. One for btnShowKb and another btnHideKb. When I click btnShowKb, it shows a QWidget. I want this QWidget to always be on top of all windows until I click btnHideKb. When it's on top, I want to activate QWidget and QMainWidget.

Can anyone suggest this?

+8
qwidget qmainwindow
source share
2 answers

Setting setWindowFlags () with Qt :: WindowStaysOnTopHint is intended 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

+10
source share

Nokia was yesterday ...

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

and a line of code that you can find:

mainMenu->setWindowFlags(Qt::WindowStaysOnTopHint); 
+2
source share

All Articles