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();
相关推荐
九章云极AladdinEdu10 分钟前
深度学习优化器进化史:从SGD到AdamW的原理与选择
linux·服务器·开发语言·网络·人工智能·深度学习·gpu算力
axban12 分钟前
QT M/V架构开发实战:QStandardItemModel介绍
开发语言·数据库·qt
猿究院-赵晨鹤26 分钟前
String、StringBuffer 和 StringBuilder 的区别
java·开发语言
I'm a winner32 分钟前
第五章:Python 数据结构:列表、元组与字典(一)
开发语言·数据结构·python
葵野寺36 分钟前
【RelayMQ】基于 Java 实现轻量级消息队列(九)
java·开发语言·rabbitmq·java-rabbitmq
大白同学4211 小时前
【C++】C++11介绍(Ⅱ)
开发语言·c++
你怎么知道我是队长1 小时前
C语言---存储类
c语言·开发语言
XIAOYU6720131 小时前
金融数学专业需要学哪些数学和编程内容?
开发语言·matlab·金融
油炸自行车2 小时前
【Qt】编写Qt自定义Ui控件步骤
开发语言·c++·qt·ui·自定义ui控件·qt4 自定义ui控件
酷飞飞2 小时前
PyQt 界面布局与交互组件使用指南
python·qt·交互·pyqt