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();
相关推荐
麦麦麦当劳大王7 小时前
【油猴脚本】Boss直聘 岗位职责复制
开发语言·前端·javascript
starzy19908 小时前
深入理解Scala Map:从实现原理到工程实践
开发语言·后端·scala
只睡四小时9 小时前
Three.js Sub-tick:漏判 60.7%→0
开发语言·javascript·性能优化·ecmascript·游戏开发·three.js·碰撞检测
码农小河669 小时前
基于SSM+JSP的高校专业信息管理系统【附源码+数据库】
java·开发语言·数据库
东鹏特饮11 小时前
系统运维(传统/通用运维)面试题
开发语言·php
今天要早睡_11 小时前
C++01_入门基础复习
开发语言·c++
黑马程序员毕设12 小时前
基于 Java 的餐饮点餐系统设计与应用报告
java·开发语言
1-1=014 小时前
C# 委托与事件
开发语言·c#
Fuyo_111914 小时前
C++ 运行时多态与虚函数机制全面剖析【面试重点】
开发语言·c++·面试
w_zero_one15 小时前
递归算法(一)
java·开发语言·算法