C++ setWindowFlags(Qt::WindowStaysOnTopHint) 隐藏 Qt 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19097323/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
setWindowFlags(Qt::WindowStaysOnTopHint) hides Qt Window
提问by swtdrgn
I want to make my Qt Window stay on top. When setWindowFlags(Qt::WindowStaysOnTopHint)
is executed, the window becomes hidden (on Windows 7).
我想让我的 Qt Window 保持在顶部。当setWindowFlags(Qt::WindowStaysOnTopHint)
被执行时,该窗口将成为(在Windows 7)隐藏。
I've also tried:
我也试过:
Qt::WindowFlags flags = windowFlags();
setWindowFlags(flags | Qt::WindowStaysOnTopHint);
And, it still does the same. What did I do wrong here?
而且,它仍然这样做。我在这里做错了什么?
回答by fxam
Call show() after you set the flag:
设置标志后调用 show() :
Qt::WindowFlags flags = windowFlags();
setWindowFlags(flags | Qt::WindowStaysOnTopHint);
show();
Check out http://doc.qt.io/qt-5/qwidget.html#windowFlags-prop