Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How keep a QWidget always on top?

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?

like image 344
Surjya Narayana Padhi Avatar asked Feb 10 '11 00:02

Surjya Narayana Padhi


2 Answers

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

like image 88
Phil Hannent Avatar answered Sep 20 '22 04:09

Phil Hannent


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);
like image 29
user3054986 Avatar answered Sep 17 '22 04:09

user3054986