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();
相关推荐
HalvmånEver7 分钟前
在 C++ :x86(32 位)和 x64(64 位)的不同
开发语言·c++·学习
amy_jork2 小时前
npm删除包
开发语言·javascript·ecmascript
浪成电火花3 小时前
(deepseek!)deepspeed中C++关联部分
开发语言·c++
茉莉玫瑰花茶3 小时前
Qt 常用控件 - 9
开发语言·qt
艾伦~耶格尔4 小时前
【数据结构进阶】
java·开发语言·数据结构·学习·面试
杜子不疼.4 小时前
《Python列表和元组:从入门到花式操作指南》
开发语言·python
WYH2874 小时前
C#控制台输入(Read()、ReadKey()和ReadLine())
开发语言·c#
祈祷苍天赐我java之术4 小时前
Java 迭代器(Iterator)详解
java·开发语言
秋氘渔5 小时前
综合案例:Python 函数知识整合 — 学生成绩管理系统
开发语言·python
我命由我123455 小时前
软件开发 - 避免过多的 if-else 语句(使用策略模式、使用映射表、使用枚举、使用函数式编程)
java·开发语言·javascript·设计模式·java-ee·策略模式·js