How keep a QWidget always on top?

Surjya Narayana Padhi picture Surjya Narayana Padhi · Feb 10, 2011 · Viewed 16.8k times · Source

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?

Answer

Phil Hannent picture Phil Hannent · Jun 21, 2011

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