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();
相关推荐
悠哉清闲几秒前
C++ MediaCodec H264解码
开发语言·c++
张人玉1 分钟前
c#中Random类、DateTime类、String类
开发语言·c#
Jinkxs34 分钟前
JavaScript性能优化实战技术
开发语言·javascript·性能优化
ydm_ymz2 小时前
C语言初阶4-数组
c语言·开发语言
presenttttt2 小时前
用Python和OpenCV从零搭建一个完整的双目视觉系统(六 最终篇)
开发语言·python·opencv·计算机视觉
逐花归海.2 小时前
『 C++ 入门到放弃 』- 多态
开发语言·c++·笔记·程序人生
卜锦元3 小时前
Go中使用wire进行统一依赖注入管理
开发语言·后端·golang
军训猫猫头3 小时前
3.检查函数 if (!CheckStart()) return 的妙用 C#例子
开发语言·c#
coding随想3 小时前
JavaScript中的系统对话框:alert、confirm、prompt
开发语言·javascript·prompt
灵哎惹,凌沃敏3 小时前
C语言/Keil的register修饰符
c语言·开发语言