平台 - Windows 7、8、10
我从 QMainWindow 创建了一个 QApplication。我希望它始终位于所有其他窗口之上。
我已经使用 Qt 标志( Qt::WindowStaysOnTopHint )来实现这一点。但是这个 Qt 标志不起作用。该应用程序是无框架应用程序。
请在下面找到我的 Qt App 的构造函数的代码。
myApp::myApp(QWidget *parent)
: QMainWindow(parent)
{
setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint );
ui.setupUi(this);
}
我怎样才能使这个标志工作?
我已经尝试了社区中几位成员建议的所有选项。我现在的代码如下
Qt::WindowFlags flags = this->windowFlags();
this->setWindowFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
ui.setupUi(this);
奇怪的事实是,这永远不会在我的机器上运行。当我创建安装程序或复制所需文件并在不同的机器(Windows 7、8、10)上运行时,我的应用程序将位于所有其他窗口之上。注意:我使用的是 Visual Studio Community Edition 2015 OS - Windows 7 Professional Service Pack 1。