13

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?

Thoys
  • 65
  • 1
  • 7
Surjya Narayana Padhi
  • 7,741
  • 25
  • 81
  • 130

2 Answers2

9

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

Phil Hannent
  • 12,047
  • 17
  • 71
  • 118
  • Thanks, also the code is shown in this question: http://stackoverflow.com/questions/2855968/how-do-i-toggle-always-on-top-for-a-qmainwindow-in-qt – Aquarius_Girl Feb 15 '12 at 08:59
6

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);
user3054986
  • 417
  • 7
  • 18