<> study QT of Qt::WindowFlags Enumeration type details

in use Qt I often see it when I design QWidget The following sentence appears in the constructor of a space :
QWidget(QWidget *parent=0,Qt::WindowFlags f=0);
QWidget *parent This code is easy to understand , Is the assignment of the parent widget .

Qt::windowFlags f=0 This code is a little confused , In fact, it specifies the window ID of the control . The value is 0 Namely Qt::Widget.

Then it is necessary to talk about the window logo settings of the control . The window identifier consists of two parts , They are window type and window prompt hint
, A window has only one window type . Window prompts define the appearance of the window , There can be multiple prompts , The window prompts to select or by bit .

Make it clear Qt::WindowFlags Enumerating types requires two concepts : Windows and parts

window : Relative independence , It can be divided into child window and parent window , The main feature is that the window has a complete border .

parts : Must exist depending on the parent window , Strong dependence , Appears inside the interface of the parent form .

With the above concept, it is easy to explain Qt::WindowFlags Enumerate the usage of type . First determine whether a control is a form , First, according to the parameters parent Assignment of , If the value is 0 Then we can judge that it is a window . Otherwise, it needs to be based on Qt::WindowFlags Enumeration type can be used to determine whether it is a window or a part .

Window type explain
Qt::Widget QWidget Default value of constructor , If the new widget has no parent , It is a separate window , Otherwise, it is a child widget .
Qt::Window Whether there is a parent widget or not , The new widget is a window , It usually has a window border and a title bar .
Qt::Dialog The new widget is a dialog box , It is QDialog Default value of constructor .
Qt::Sheet The new widget is a Macintosh form (sheet).
Qt::Drawer The new widget is a Macintosh drawer (drawer).
Qt::Popup The new widget is a pop-up top-level window .
Qt::Tool
The new widget is a tool window , It is usually a small window for displaying tool buttons . If a tool window has a parent widget , It will appear above the parent widget , otherwise , Will be equivalent to using Qt::WindowStayOnTopHint Tips .
Qt::ToolTip The new widget is a prompt window , No title bar and window border .
Qt::SplashScreen The new widget is a welcome window , It is QSplashScreen Default value of constructor .
Qt::Desktop The new widget is the desktop , It is QDesktopWidget Default value of constructor .
Qt::SubWindow The new widget is a child window , Whether the widget has a parent or not .
Window tips explain
Qt::MSWindowsFiredSizeDialogHint by Windows The windows on the system are decorated with a narrow dialog box border , Usually this prompt is used for Fixed Size dialog boxes .
Qt::MSWindowsOwnDC by Window Windows on the system add their own display context menu
Qt::X11BypassWindowManagerHint
Completely ignore window manager , Its function is to create a window without a window border that is not managed at all ( here , The user cannot use the keyboard for input , Unless manually called QWidget::activateWindow function ).
Qt::FramelessWindowHint Produces a window without a window border , At this time, the user cannot move the window and change its size .
Qt::CustomizeWindowHint Turn off the default window title prompt .
Qt::WindowTitleHint Decorate the window with a title bar .
Qt::WindowSystemMenuHint Add a window system menu to the window , And add a close button as much as possible
Qt::WindowMinmizeButtonHint Add a " minimize " Button
Qt::WindowMaximizeButtonHint Add a " Maximize " Button
Qt::WindowMinMaxButtonsHint Add a " minimize " Button and a " Maximize " Button .
Qt::WindowContextHelpButtonsHint Add a " Context help " Button
Qt::WindowStaysOnTopHint Notification window system , This window should be left on top of all other windows .
Qt::WindowType_Mask A mask used to extract the window class part of the window ID .
be careful : Window tips are only valid for top-level windows .

Enumeration type Qt::WindowFlags Low order 1 Bytes are used for the window type specified for the widget ,0x00000000~0x00000012 The 11 Window types .Qt::WindowFlags The high byte of defines the window prompt , Window prompt can be pressed bit or operation , for example :
Qt::windowContextHelpButtonHint | Qt::windowMaximizeButtonHint

discharge Qt::WindowFlags The window prompt part of the 0 Time , Window prompts don't work . When a window prompt is applied , To make other window prompts work , Must use bit or operation ( If the window system supports these window prompts ). for example :
Qt::windowFlags flags = Qt::window; widget->setWindowFlags(flags);
widget A widget is a window , It has the appearance of a normal window ( With window border , Title Bar ,“ minimize ” Button ,“ Maximize ” Buttons and “ close ” Button, etc ), Window prompts do not work at this time . for example :
flags |= Qt::WindowTitleHint; widget->setWindowFlags(flags);

The execution of the above code will make windowing work . stay Windows In the system ,widget A widget is a window . It only has a title bar , No, “ minimize ” Button ,“ Maximize ” Buttons and “ close ” Button, etc . and X11 The prompt window was ignored Qt::WindowTitleHint, for example , In the red flag Linux Workstations and SUSE On the system , The above code does not work .

stay Windows In the system , If you need a sky sword " minimize " Button , The window ID of the widget must be reset , The details are as follows :
flags |= Qt::WindowMinimizeButtonHint; widget->setWindowFlags;
If you want to cancel the set window 0 Tips , The specific codes are as follows :
flags &= Qt::WindowType_Mask; widget->setWindowFlags(flags);
So much said , Let's see how to use it .
this->setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
// If you want to remove an attribute, add it directly ~ Can this->setWindowFlags(windowFlags() &
~Qt::WindowMaximizeButtonHint);// Remove the maximize button

Technology
©2019-2020 Toolsou All rights reserved,
The 11th Blue Bridge Cup python The real topic of the University Group National Games JavaSwing To achieve a simple Lianliankan games 【Spring Source code analysis 】42-@Conditional Detailed explanation element-ui Step on pit record 2019PHP Interview questions ( Continuously updated )PHPJava Misunderstanding —— Method overloading is a manifestation of polymorphism ? First issue 500 100 million , Set up a new Department , What is Tencent going to do ? Google chrome The browser can't open the web page , But what if other browsers can open it ? Regression of dependent variable order categories (R language )【Golang Basic series 10 】Go language On conditional sentences if