从这里开始:http://doc.qt.io/qt-4.8/qt-widgets-windowflags-example.html
if (flags & Qt::MSWindowsFixedSizeDialogHint)
text += "\n| Qt::MSWindowsFixedSizeDialogHint";
if (flags & Qt::X11BypassWindowManagerHint)
text += "\n| Qt::X11BypassWindowManagerHint";
if (flags & Qt::FramelessWindowHint)
text += "\n| Qt::FramelessWindowHint";
if (flags & Qt::WindowTitleHint)
text += "\n| Qt::WindowTitleHint";
if (flags & Qt::WindowSystemMenuHint)
text += "\n| Qt::WindowSystemMenuHint";
if (flags & Qt::WindowMinimizeButtonHint)
text += "\n| Qt::WindowMinimizeButtonHint";
if (flags & Qt::WindowMaximizeButtonHint)
text += "\n| Qt::WindowMaximizeButtonHint";
if (flags & Qt::WindowCloseButtonHint)
text += "\n| Qt::WindowCloseButtonHint";
if (flags & Qt::WindowContextHelpButtonHint)
text += "\n| Qt::WindowContextHelpButtonHint";
if (flags & Qt::WindowShadeButtonHint)
text += "\n| Qt::WindowShadeButtonHint";
if (flags & Qt::WindowStaysOnTopHint)
text += "\n| Qt::WindowStaysOnTopHint";
if (flags & Qt::CustomizeWindowHint)
text += "\n| Qt::CustomizeWindowHint";
但是当我这样做时:
Qt :: WindowFlags flags = 0;
flags = flags | Qt :: WindowStaysOnTopHint;
flags = flags & Qt :: WindowMinimizeButtonHint;
window->setWindowFlags (flags);
第一个标志被覆盖。有什么方法可以同时设置多个标志?
答案 0 :(得分:12)
window->setWindowFlags (Qt::WindowStaysOnTopHint | Qt::WindowMinimizeButtonHint );
供您参考:
Window Flags作为 OR组合存储在QFlags<WindowType>
类型的对象中,其中WindowType是枚举。
存储标志时,使用按位 OR运算符组合它们的值。
有关详细信息,请参阅Qt documentation。
答案 1 :(得分:2)
尝试:
Qt :: WindowFlags flags = 0;
flags = flags | Qt :: WindowStaysOnTopHint;
flags = flags | Qt :: WindowMinimizeButtonHint;
window->setWindowFlags (flags);