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.05 分钟前
L C D
开发语言·stm32
wjs202410 分钟前
NumPy 创建数组
开发语言
黎雁·泠崖11 分钟前
Java继承细节:子类继承父类成员的底层逻辑
java·开发语言
冷雨夜中漫步14 分钟前
Java中strip与trim()的区别
java·开发语言
xb113220 分钟前
C#多线程编程入门概念
开发语言
froginwe1123 分钟前
PostgreSQL HAVING 子句详解
开发语言
yugi98783831 分钟前
基于MATLAB的延迟求和(DAS)波束形成算法实现
开发语言·算法·matlab
冷雨夜中漫步34 分钟前
Python入门——字符串
开发语言·python
Yvonne爱编码34 分钟前
Java 接口学习核心难点深度解析
java·开发语言·python
黎雁·泠崖1 小时前
Java继承入门:概念+特点+核心继承规则
java·开发语言