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();
相关推荐
qq_401700416 分钟前
QT C++ 好看的连击动画组件
开发语言·c++·qt
t1987512821 分钟前
广义预测控制(GPC)实现滞后系统控制 - MATLAB程序
开发语言·matlab
报错小能手34 分钟前
线程池学习(六)实现工作窃取线程池(WorkStealingThreadPool)
开发语言·学习
一条咸鱼_SaltyFish36 分钟前
[Day10] contract-management初期开发避坑指南:合同模块 DDD 架构规划的教训与调整
开发语言·经验分享·微服务·架构·bug·开源软件·ai编程
额呃呃43 分钟前
STL内存分配器
开发语言·c++
七点半77044 分钟前
c++基本内容
开发语言·c++·算法
嵌入式进阶行者1 小时前
【算法】基于滑动窗口的区间问题求解算法与实例:华为OD机考双机位A卷 - 最长的顺子
开发语言·c++·算法
No0d1es1 小时前
2025年12月 GESP CCF编程能力等级认证Python三级真题
开发语言·php
lalala_lulu1 小时前
什么是事务,事务有什么特性?
java·开发语言·数据库
CCPC不拿奖不改名1 小时前
python基础:python语言中的函数与模块+面试习题
开发语言·python·面试·职场和发展·蓝桥杯