<> 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,
What are the protection measures for website security ? Talking about uni-app Page value transfer problem Remember once EventBus Project issues caused by memory leaks I've been drinking soft water for three years ? What is the use of soft water and water softener Time conversion front desk will 2020-07-17T03:07:02.000+0000 Into 2020-07-17 11:07:02 Chuan Shen Count the number of letters (java Language implementation ) Time format 2020-01-13T16:00:00.000Z Medium T and Z What do they mean , How to deal with it msf Generate Trojan horse attack android mobile phone The world's first free open source ERP Odoo Ubuntu The best development environment What's the difference in server prices ?