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();
相关推荐
AIFarmer2 小时前
【无标题】
开发语言·c++·算法
昇腾CANN3 小时前
TileLang-Ascend 算子性能优化方法与实操
开发语言·javascript·性能优化·昇腾·cann
沐知全栈开发3 小时前
ionic 手势事件详解
开发语言
lsx2024063 小时前
Bootstrap 按钮
开发语言
神仙别闹3 小时前
基于 Python 实现 BERT 的情感分析模型
开发语言·python·bert
禾叙_3 小时前
【langchain4j】结构化输出(六)
java·开发语言
NQBJT3 小时前
VS Code配置Python人工智能开发环境
开发语言·人工智能·vscode·python
byoass3 小时前
智巢AI知识库深度解析:企业文档管理从大海捞针到精准狙击的进化之路
开发语言·网络·人工智能·安全·c#·云计算
南境十里·墨染春水4 小时前
C++笔记 STL——set
开发语言·c++·笔记
L1624764 小时前
Win11 共享→Windows Server 访问故障总结(极简可复用)
开发语言·windows·php