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();
相关推荐
CoderCodingNo3 分钟前
【GESP】C++五级练习题 luogu-P3353 在你窗外闪耀的星星
开发语言·c++·算法
NMIXX爻12 分钟前
线程控制 下
java·开发语言·jvm
Howrun77714 分钟前
C++ 类间交互
开发语言·c++
2401_8576835429 分钟前
C++代码静态检测
开发语言·c++·算法
2401_8384725134 分钟前
内存泄漏自动检测系统
开发语言·c++·算法
开发者小天39 分钟前
python中的class类
开发语言·python
2501_933329551 小时前
Infoseek数字公关AI中台技术解析:如何构建企业级舆情监测与智能处置系统
开发语言·人工智能
m0_706653231 小时前
基于C++的爬虫框架
开发语言·c++·算法
梵刹古音1 小时前
【C语言】 数据类型的分类
c语言·开发语言
diediedei1 小时前
嵌入式数据库C++集成
开发语言·c++·算法