4

From here: 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";

But when I do this:

Qt :: WindowFlags flags = 0;

flags = flags | Qt :: WindowStaysOnTopHint;
flags = flags & Qt :: WindowMinimizeButtonHint;
window->setWindowFlags (flags);

The first flag gets overwritten. What is the way to set more than one flags at the same time?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411

2 Answers2

13
window->setWindowFlags (Qt::WindowStaysOnTopHint | Qt::WindowMinimizeButtonHint );

For your information:

Window Flags are stored as OR combinations of the flags inside an object of the type QFlags<WindowType> where WindowType is an enum.

When storing the flags you combine their values using the bitwise OR operator.

For further information see the Qt documentation.

Exa
  • 4,020
  • 7
  • 43
  • 60
2

Try with :

Qt :: WindowFlags flags = 0;

flags = flags | Qt :: WindowStaysOnTopHint;
flags = flags | Qt :: WindowMinimizeButtonHint;
window->setWindowFlags (flags);
Adrien BARRAL
  • 3,474
  • 1
  • 25
  • 37