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();
相关推荐
ZPC82108 小时前
如何创建一个单例类 (Singleton)
开发语言·前端·人工智能
超绝振刀怪8 小时前
【C++多态】
开发语言·c++
workflower8 小时前
AI制造-推荐初始步骤
java·开发语言·人工智能·软件工程·制造·需求分析·软件需求
魔都吴所谓8 小时前
【Python】从零构建:IP地理位置查询实战指南
开发语言·python·tcp/ip
环黄金线HHJX.9 小时前
【吧里BaLi社区】
开发语言·人工智能·qt·编辑器
oioihoii9 小时前
Cursor根本无法调试C++
开发语言·c++
GISer_Jing9 小时前
Agent多代理架构:子代理核心机制解密
开发语言·人工智能·架构·aigc
jie1889457586610 小时前
c语言------
c语言·开发语言
AI逐月11 小时前
解决 ComfyUI 插件安装后 Nanobind 报错问题:soxr 版本冲突原理解读
开发语言·python