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();
相关推荐
极客先躯1 分钟前
高级java每日一道面试题-2025年3月21日-微服务篇[Nacos篇]-什么是Nacos?
java·开发语言·微服务
try again!15 分钟前
rollup.js 和 webpack
开发语言·javascript·webpack
du fei26 分钟前
C# 窗体应用(.FET Framework) 线程操作方法
开发语言·c#
du fei28 分钟前
C#文件操作
开发语言·c#
月亮有痕迹诶40 分钟前
【C++】智能指针
开发语言·c++·c++11
搞不懂语言的程序员1 小时前
装饰器模式详解
开发语言·python·装饰器模式
王禄DUT1 小时前
化学方程式配平 第33次CCF-CSP计算机软件能力认证
开发语言·c++·算法
Yang-Never1 小时前
Open GL ES ->纹理贴图,顶点坐标和纹理坐标组合到同一个顶点缓冲对象中进行解析
android·java·开发语言·android studio·贴图
DreamByte1 小时前
C++菜鸟教程 - 从入门到精通 第五节
开发语言·c++·算法
Ljugg1 小时前
把doi直接插入word中,然后直接生成参考文献
开发语言·c#·word