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();
相关推荐
wuyk5552 小时前
第2章:六步换相原理全解+STM32工程实战
c语言·开发语言·stm32·单片机·嵌入式硬件
hey_sml2 小时前
JAVA每日一学---CompletableFuture中thenApply与thenCompose区别详解
java·开发语言
萧瑟余晖3 小时前
Java深入解析篇十七之SpringCloud
java·开发语言
ttod_qzstudio4 小时前
Java 常用语法极简通关(五):类与对象——字段、方法、构造器、this 与 static
java·开发语言·python
我是小灰灰吖5 小时前
QT在线安装器使用指南:从下载到配置完整教程
linux·qt·ubuntu
萧瑟余晖5 小时前
Java深入解析篇十七之Spring Security
java·开发语言·spring
C++ 老炮儿的技术栈7 小时前
从 Qt Designer 属性编辑器的层级可以看到继承链
c语言·数据库·c++·qt·sqlite·visual studio
二十雨辰8 小时前
[Java]-Spring面试题
java·开发语言
_oP_i8 小时前
python 后缀 mjs文件
开发语言·python
萧瑟余晖9 小时前
Java深入解析篇二十二之虚拟线程
java·开发语言