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();
相关推荐
hxjhnct几秒前
JavaScript 的 new会发生什么
开发语言·javascript
少控科技4 分钟前
QT进阶日记004
开发语言·qt
阿杰 AJie8 分钟前
Lambda 表达式大全
开发语言·windows·python
格鸰爱童话9 分钟前
python基础总结
开发语言·python
叁散20 分钟前
实验项目4 光电式传感器原理与应用(基于Matlab)
开发语言·matlab
先做个垃圾出来………20 分钟前
Python try-except-else 语句详解
开发语言·python
进击的小头22 分钟前
为什么C语言也需要设计模式
c语言·开发语言·设计模式
Sylvia-girl38 分钟前
Lambda表达式
java·开发语言
softshow102639 分钟前
html2canvas + jspdf实现页面导出成pdf
开发语言·javascript·pdf
Java程序员威哥1 小时前
Java应用容器化最佳实践:Docker镜像构建+K8s滚动更新(生产级完整模板+避坑指南)
java·开发语言·后端·python·docker·kubernetes·c#