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_3363139313 分钟前
java基础-IO流(打印流)
java·开发语言
缺点内向13 分钟前
C#: 精准掌控Excel工作流——激活工作表与选择单元格实战
开发语言·c#·excel
峥无42 分钟前
《二叉搜索树:动态数据管理的利器,平衡树的基石》
开发语言·c++·二叉搜索树
CoderCodingNo43 分钟前
【GESP】C++五级真题(数论, 贪心思想考点) luogu-B4070 [GESP202412 五级] 奇妙数字
开发语言·c++·算法
一刻钟.1 小时前
DataGridView和定时器
开发语言·c#
墨辰JC1 小时前
C语言可变参数讲解:stdarg.h应用
c语言·开发语言·蓝桥杯·内存·蓝桥杯嵌入式
Larry_Yanan1 小时前
Qt多进程(八)消息队列(基于文件)
开发语言·qt
毕设源码-钟学长1 小时前
【开题答辩全过程】以 基于java旅游网站的设计与实现为例,包含答辩的问题和答案
java·开发语言·旅游
0和1的舞者1 小时前
接口自动化测试详解(二):requests 请求封装与 Pytest 框架全实战
开发语言·自动化测试·python·测试开发·接口·测试
C语言小火车1 小时前
C++右值引用与转移语义详解
c语言·开发语言