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();
相关推荐
黎雁·泠崖10 分钟前
吃透Java操作符入门:分类差异+进制转换+原反补码 核心前置知识(Java&C对比)
java·c语言·开发语言
满栀58511 分钟前
三级联动下拉框
开发语言·前端·jquery
名字不好奇14 分钟前
C++虚函数表失效???
java·开发语言·c++
e***985720 分钟前
MATLAB高效算法实战:从基础到进阶优化
开发语言·算法·matlab
yaoxin52112320 分钟前
286. Java Stream API - 使用Stream.iterate(...)创建流
java·开发语言
爱说实话21 分钟前
C# 20260112
开发语言·c#
float_六七24 分钟前
JS比较运算符:从坑点速记到实战口诀
开发语言·javascript·ecmascript
CoderCodingNo24 分钟前
【GESP】C++五级练习(前缀和练习) luogu-P1387 最大正方形
开发语言·c++·算法
yong999026 分钟前
信号分形维数计算方法与MATLAB实现
开发语言·人工智能·matlab
r_oo_ki_e_28 分钟前
java23--异常
java·开发语言