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();
相关推荐
lexiangqicheng几秒前
JS-- for...in和for...of
开发语言·前端·javascript
我是老孙19 分钟前
windows10 php报错
开发语言·php
y1021210422 分钟前
Python训练营打卡Day42
开发语言·javascript·ecmascript
2301_8050545633 分钟前
Python训练营打卡Day46(2025.6.6)
开发语言·python
曹勖之43 分钟前
撰写脚本,通过发布/joint_states话题改变机器人在Rviz中的关节角度
开发语言·python·机器人·ros2
不惑_1 小时前
用 PyQt5 打造一个可视化 JSON 数据解析工具
开发语言·qt·json
梓仁沐白1 小时前
【Kotlin】注解&反射&扩展
开发语言·python·kotlin
@老蝴1 小时前
C语言 — 编译和链接
c语言·开发语言
本郡主是喵2 小时前
并发编程 - go版
java·服务器·开发语言
努力学习的小廉2 小时前
我爱学算法之—— 前缀和(中)
开发语言·redis·算法