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();
相关推荐
一枝小雨8 分钟前
【C++】Vector完全指南:动态数组高效使用
开发语言·c++·笔记·vector·学习笔记·std库
诗书画唱17 分钟前
【前端教程】JavaScript DOM 操作实战案例详解
开发语言·前端·javascript
jiaway38 分钟前
【C语言】第一课 环境配置
c语言·开发语言
小红帽2.01 小时前
从零构建一款开源在线客服系统:我的Go语言实战之旅
开发语言·golang·开源
slim~1 小时前
Java基础第9天总结(可变参数、Collections、斗地主)
java·开发语言
ComputerInBook2 小时前
C++编程语言:标准库:第37章——正则表达式(Bjarne Stroustrup)
开发语言·c++·正则表达式
A尘埃2 小时前
智能工单路由系统(Java)
java·开发语言·智能工单
Source.Liu3 小时前
【Python基础】 13 Rust 与 Python 注释对比笔记
开发语言·笔记·python·rust
qq_195551693 小时前
代码随想录70期day3
开发语言·python
XXYBMOOO3 小时前
Qt UDP 通信类详解与实现
开发语言·网络·c++·qt·网络协议·ui·udp