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();
相关推荐
雪域迷影7 分钟前
C++ 11 中的move赋值运算符
开发语言·c++·move
jf加菲猫15 分钟前
第2章 Hello World
开发语言·c++·qt·ui
todoitbo1 小时前
Rust新手第一课:Mac环境搭建踩坑记录
开发语言·macos·rust
laplace01231 小时前
PyQt5 + Qt Designer配置指令
开发语言·qt
nvd112 小时前
Python 迭代器 (Iterator) vs. 生成器 (Generator)
开发语言·python
HalvmånEver2 小时前
Linux:基础开发工具(三)
linux·运维·服务器·开发语言·学习·gcc/g++
后端小张2 小时前
【JAVA 进阶】Spring Boot 注解体系与工程实践
java·开发语言·spring boot·后端·spring·spring cloud·java-ee
倔强的石头1062 小时前
Rust实战:使用Axum和SQLx构建高性能RESTful API
开发语言·rust·restful
q***46522 小时前
对基因列表中批量的基因进行GO和KEGG注释
开发语言·数据库·golang