Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the multiple flags in QMainWindow?

Tags:

c++

qt

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?

like image 457
Aquarius_Girl Avatar asked Dec 09 '22 02:12

Aquarius_Girl


1 Answers

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.

like image 69
Exa Avatar answered Dec 11 '22 16:12

Exa