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();
相关推荐
feixing_fx7 小时前
第一个 JS 程序:在浏览器控制台和 Node 中分别运行
开发语言·前端·javascript·前端框架·ecmascript
Evand J8 小时前
【MATLAB例程】二维IMM-UKF定位,基于四个基站的AOA与测距辅助
开发语言·matlab
feixing_fx9 小时前
变量与声明:let、const、var 的选择边界
开发语言·前端·javascript·前端框架
个 人 练 习 生9 小时前
C++:从零基础到深入了解vector的使用
开发语言·c++·经验分享·学习·程序人生·stl
ShineWinsu10 小时前
对于Qt窗口:QMainWindow、QMenuBar、Qmenu、QAction的解析
c++·qt·菜单·qmainwindow·qaction·qmenu·qmenubar
H.莓飛10 小时前
【C++】【STL】stack_OJ题
服务器·c语言·开发语言·数据结构·c++·算法·visual studio
hudd66810 小时前
JavaEE 初阶 - 文件操作和IO
java·开发语言·java-ee
starzy199011 小时前
深入理解Scala隐式参数:上下文流转
开发语言·python·scala
feixing_fx12 小时前
JavaScript 是什么:从浏览器脚本到通用编程语言
开发语言·前端·javascript·前端框架·ecmascript
惜.己14 小时前
Java结合idea简单使用Playwright
java·开发语言·自动化