setWindowFlags(Qt::WindowStaysOnTopHint) 隐藏 Qt 窗口

2022-01-18 00:00:00 windows qt5 qt windows-7 c++

我想让我的 Qt 窗口保持在顶部.执行 setWindowFlags(Qt::WindowStaysOnTopHint) 时,窗口变为隐藏状态(在 Windows 7 上).

I want to make my Qt Window stay on top. When setWindowFlags(Qt::WindowStaysOnTopHint) is executed, the window becomes hidden (on Windows 7).

我也试过了:

Qt::WindowFlags flags = windowFlags();
setWindowFlags(flags | Qt::WindowStaysOnTopHint);

而且,它仍然是一样的.我在这里做错了什么?

And, it still does the same. What did I do wrong here?

推荐答案

设置标志后调用 show():

Call show() after you set the flag:

Qt::WindowFlags flags = windowFlags();
setWindowFlags(flags | Qt::WindowStaysOnTopHint);
show();

查看 http://doc.qt.io/qt-5/qwidget.html#windowFlags-prop

相关文章