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();
相关推荐
smchaopiao22 分钟前
Python中字典与列表合并的问题与解决方法
开发语言·python
敲代码的瓦龙39 分钟前
Java?面向对象三大特性!!!
java·开发语言
2501_9216494941 分钟前
期货 Tick 级数据与基金净值历史数据 API 接口详解
开发语言·后端·python·websocket·金融·区块链
野犬寒鸦44 分钟前
Redis复习记录day1
服务器·开发语言·数据库·redis·缓存
小菜鸡桃蛋狗1 小时前
C++——类和对象(下)
开发语言·c++
骑龙赶鸭1 小时前
java开发项目中遇到的难点,面试!
java·开发语言·面试
张人玉1 小时前
C#通讯(上位机)常用知识点
开发语言·c#·通讯·上位机开发
NGC_66111 小时前
Java线程池七大核心参数介绍
java·开发语言
crescent_悦1 小时前
C++:Highest Price in Supply Chain
开发语言·c++