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();
相关推荐
带鱼吃猫6 小时前
C++STL:从 0 到 1 手写 C++ string以及高频易错点复盘
开发语言·c++
u0109272716 小时前
代码覆盖率工具实战
开发语言·c++·算法
码云数智-大飞6 小时前
零拷贝 IPC:用内存映射文件打造 .NET 高性能进程间通信队列
java·开发语言·网络
懈尘6 小时前
深入理解Java的HashMap扩容机制
java·开发语言·数据结构
Beginner x_u6 小时前
JavaScript 核心知识索引(面试向)
开发语言·javascript·面试·八股
yqd6666 小时前
RabbitMQ用法和面试题
java·开发语言·面试
白日梦想家6816 小时前
JavaScript性能优化实战系列(三篇完整版)
开发语言·javascript·性能优化
请注意这个女生叫小美6 小时前
C语言 实例20 25
c语言·开发语言·算法
fundroid6 小时前
Kotlin 泛型进阶:in、out 与 reified 实战
android·开发语言·kotlin
枫叶丹46 小时前
【Qt开发】Qt系统(十一)-> Qt 音频
c语言·开发语言·c++·qt·音视频