Platform - Windows 7,8,10
I have created a QApplication from QMainWindow. I want it to remain always on top of all other windows.
I have used Qt flags ( Qt::WindowStaysOnTopHint ) to achieve this. But this Qt flag does not work. The application is a frameless application.
Please find below the code of the constructor of my Qt App.
myApp::myApp(QWidget *parent)
: QMainWindow(parent)
{
setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint );
ui.setupUi(this);
}
How can I make this flag work ?
I have tried all the options suggested by several members of the community. My present code is as follows
Qt::WindowFlags flags = this->windowFlags();
this->setWindowFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
ui.setupUi(this);
Strange fact is that this never works on my machine. When I create an installer or copy the required files and run on a different machines(Windows 7, 8, 10) then I get my application on top of all other windows. Note: I am using Visual Studio Community Edition 2015 OS - Windows 7 Professional Service Pack 1.