qt窗口置顶

设置Qt::WindowStaysOnTopHint

bash 复制代码
 this->setWindowFlags(Qt::Tool| Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint|Qt::X11BypassWindowManagerHint);

Qt::WindowStaysOnTopHint帮助文档

bash 复制代码
Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly.

windows下

如果不是第一时间启动,还需在类构造函数设置

cpp 复制代码
#ifdef Q_OS_WIN32
    ::SetWindowPos(HWND(this->winId()), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
#endif

唤醒

cpp 复制代码
#ifdef Q_OS_WIN32
    ::SetWindowPos(HWND(this->winId()), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
#endif
    this->show();
    this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
    this->raise();
    this->activateWindow();
相关推荐
萧鼎10 小时前
Python PyWavelets(pywt)库完整技术指南:从小波理论到工程实践
开发语言·python
天下无敌笨笨熊10 小时前
kotlin函数式编程
开发语言·数据库·kotlin
MediaTea10 小时前
Python 装饰器:@property_name.deleter
开发语言·python
清风拂山岗 明月照大江10 小时前
TCP/IP网络编程_hello,world!
开发语言·c++
向阳是我10 小时前
v0.app的next.js项目自动部署到宝塔服务器教程
服务器·开发语言·javascript·github·ai编程
pengzhuofan10 小时前
Java开发中的AI Prompt管理指南
java·开发语言·prompt
IOT-Power10 小时前
QT QSerialPort 串口不稳定,串口是否使用独立线程
qt
夏霞10 小时前
c# ActiveMQ
开发语言·c#·activemq
网络小白不怕黑10 小时前
IPv6核心技术与NDP协议深度解析:从地址架构到邻居发现
开发语言·架构·php
AI科技星10 小时前
伟大的跨越:从超距作用到时空运动——牛顿与张祥前引力场方程的终极对比
开发语言·数据结构·经验分享·线性代数·算法