【问题标题】:setWindowFlags(Qt::WindowStaysOnTopHint) hides Qt WindowsetWindowFlags(Qt::WindowStaysOnTopHint) 隐藏 Qt 窗口
【发布时间】:2013-10-06 11:59:15
【问题描述】:

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

我也试过了:

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

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

【问题讨论】:

    标签: c++ windows qt windows-7 qt5


    【解决方案1】:

    设置标志后调用 show():

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

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

    【讨论】:

    • 这个答案没有错,只是:windowFlags / setWindowFlags 是您正在使用的窗口的子窗口。所以它可能需要 ThisWindow.windowFlags() 和 ThisWindow.setWindowFlags(...) 和 ThisWindow.show() 取决于你的上下文。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-09
    相关资源
    最近更新 更多