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();
相关推荐
gs801407 分钟前
检查当前 Docker 使用的 默认运行时(default runtime)方法
java·开发语言·eureka
老猿阿浪14 分钟前
JavaScript性能优化:从青铜到王者的进阶之路
开发语言·javascript·性能优化
Dovis(誓平步青云)26 分钟前
解构C++高级命名空间:构建空间作用域·控制兼容
开发语言·c++·经验分享·笔记·学习方法
一只蒟蒻ovo1 小时前
操作系统导论——第26章 并发:介绍
java·开发语言
TPBoreas5 小时前
Jenkins 改完端口号启动不起来了
java·开发语言
TE-茶叶蛋5 小时前
Vuerouter 的底层实现原理
开发语言·javascript·ecmascript
云闲不收6 小时前
设计模式原则
开发语言
秋名RG6 小时前
深入解析建造者模式(Builder Pattern)——以Java实现复杂对象构建的艺术
java·开发语言·建造者模式
技术求索者7 小时前
c++学习
开发语言·c++·学习
山猪打不过家猪7 小时前
(二)毛子整洁架构(CQRS/Dapper/领域事件处理器/垂直切片)
开发语言·.net