There are many UI components in Qt Designer. Each component should have configurable properties. In this blog post, we will take a look at them briefly
1. Interface components
Qt Designer provides eight classes of interface visualization components: Layout components, Spacers, Buttons, Item Views, Item Widgets, Containers, Input components Widgets and Display Widgets. When designing Qt Designer’s application interface, you can drag components with various functions to the window for application visual interface design, and each component can specify different properties.
1.1 Layouts
Layout components include Vertical Layout, Horizontal Layout, Grid Layout, and Form Layout.
1.2 separating Components (Spacers)
The separation components include: Horizontal Spacer, Vertical Spacer.
1.3 Buttons
Button components include: Push Button, Tool Button, Radio Button, Check Box, Command Link Button, Dialog Button.
1.4 Item Views
The entry views include List View, Tree View, Table View, Column View, and Undo View.
1.5. Item Widgets
Table components include List Widget, Tree Widget, and Table Widget.
1.6 Containers components
Container components include: Group Box, you can add content inside and modify the header, Scroll Area, Tool Box, Tab Widget, Stacked Widget, Need signal start), Frame (layout with borders), Widget (layout without borders), MDI Area (column display), Dock Widget (floating window), QAxWidget (only available in Windows).
1.7 Input Widgets
The input components include: Combo Box, Font Combo Box, Line Edit, Text Edit Only Text, pictures and animation can be viewed), Plain Text Edit, Spin Box, Double Spin Box, Time Edit, Data Edit, Data/Time Edit (time and date), Dial (compass), Horizontal Scroll Bar, Vertical Scroll Bar, Horizontal Slider, Vertical Slider, Key Sequence Edit shortcut.
1.8 Display Widgets
Display components include: Label (Label component, You can View Text, web pages, pictures, animations, etc.), Text Browser, Graphics View, Calendar Widget, LCD Number, Progress, etc Bar, Horizontal Line, Vertical Line, OpenGL Widget (Open Graphics Library) You can display graphics (both 2D and 3D graphics), QQuickWidgets (load QML files) in PyQt and Qt applications.
2. Component properties
In the second part, there is a lot of reference and learning about this article: Designer component property editing interface related to the QWidget class properties, many details can be referred to this blog post.
Each component can be set in the Qt Designer property editing section, as shown below:
The properties of each component are different. Here is an example of the QWidget window, as shown below:
Let’s take a look
As can be seen, the topmost node is the component’s corresponding parent class (Form). The nodes arranged from top to bottom are basically arranged in the manner of parent class on top and subclass on bottom, which well reflects the inheritance relationship of classes and which class provides the related attributes.
Enabled attribute
The Enabled property is used to indicate whether a component is available. Components of a component can receive and process mouse and keyboard events, but cannot receive and process mouse and keyboard events when the component is unavailable.
The enabled attribute defaults to True. Some components display themselves differently when disabled. For example, a button might have its label grayed out.
The attributes that control the size of the component include Geometry, sizePolicy, minimumSize, maximumSize, sizeIncrement, and baseSize, which control the initial size and dynamic sizing of the component. The Geometry of the property configuration interface defines the initial size of the component, while other attributes are related to controlling the size of the component when it resizes.
Geometry properties
The Geometry attribute holds the position and size of the component relative to its parent object. Qt actually represents the position and size of the component in a rectangle, including the upper-left coordinate position, length, and width.
SizePolicy property
The sizePolicy property is used to describe how components are scaled in layout management. This setting is not valid when the part is not in the layout manager.
The sizePolicy attribute consists of four values, which are horizontal policy, vertical policy, horizontal stretch, and vertical stretch.
The Layout of the Python-PyQt5 development
MinimumSize properties
The mimimumSize property represents the minimum size, in pixels, that a component can be reduced to and cannot be reduced further. If the component is in the layout manager and the layout manager has set the minimum size, the minimum size of the component itself is determined by the mimimumSize of the component, and the layout manager Settings do not take effect.
MaximumSize properties
The maximumSize property represents the maximumSize that the component can be enlarged to, beyond which it cannot be enlarged further. The default maximum value for a component is (16777215,16777215).
SizeIncrement properties
The sizeIncrement attribute represents the cardinality (in pixels) of each increment when the component is resized. The actual sizeIncrement formula is as follows: width = baseSize().width() + i * sizeIncrement().width() height = baseSize().height() + j * sizeIncrement().height()
Where I and j are non-negative integers.
BaseSize properties
The baseSize property is the baseSize (in pixels) of a component. If a component has sizeIncrement, this property is used to calculate the appropriate value to which the component should be resized when resizing the component. The default value is (0,0).
The palette properties
The Palette property, which manages all colors of the control and form, can be used to manage the appearance and composition of the control.
The font properties
In the font property, you can set the font properties of the component, including the font Family, Size, Bold, Italic, Underline, Strikeout, and so on.
Cursor attributes
The cursor property saves the mouse cursor shape of the component. When the mouse is placed over the component, the cursor shape set by the property will be displayed. The range and meaning of the value are shown as follows:
MouseTracking properties
The mouseTracking attribute is used to save whether mouseTracking is enabled, which is disabled by default. If this function is disabled, the corresponding component only receives the mouse movement event when the mouse moves and at least one mouse button is pressed. If mouse tracking is enabled, any mouse movement event component receives it.
TabletTracking properties
The tabletTracking property holds whether to enable tabletTracking for a component, which is not available by default. Without tablet tracking enabled, the component only receives the stylus movement event when the stylus touches the tablet or when at least one stylus key is pressed. If the component has tablet tracking enabled, the component can receive stylus movement events as the stylus approaches but does not actually touch the tablet. This can be used to monitor the position of the operation as well as the auxiliary operation functions of the component (such as rotation and tilt), and provide an information interface to the graphical interface for these operations.
FocusPolicy properties
The focusPolicy property sets the focusPolicy for the component. The parameters are described as follows:
- NoFocus: The component does not support focus;
- TabFocus: The Tab key is used to obtain the focus.
- ClickFocus: Click down to get focus;
- StrongFocus: Tab and mouse press to get focus;
- WheelFocus: Scroll the mouse wheel to get focus.
ContextMenuPolicy properties
The contextMenuPolicy property is the component’s shortcut menu policy, which is triggered by right-clicking on the part. The parameters are described as follows:
Source: CSDN blogger Old Ape Python
AcceptDrops properties
The acceptDrops property indicates whether the current component accepts mouse drop events. Mouse drops should be combined with mouse drops. In Qt Designer, you can use the acceptDrops property to set whether the component accepts mouse drop events. If the part accepts drag and drop, the drag event is sent to the first part that accepts the drag under the current mouse cursor when the mouse is dragged.
If the component sets the acceptDrops property to True, it informs the system that the component accepts mouse-drop events.
WindowTitel properties
The windowTitle property sets the windowTitle.
WindowIcon properties
The windowIcon property sets the windowIcon.
WindowOpacity properties
WindowOpacity property is a floating point number indicating component transparency, with 1 fully opaque and 0 fully transparent. The default is 1.
ToolTip attribute
The toolTip property sets the toolTip information for the component. The toolTip information will appear in a small box when the mouse is placed over the control.
ToolTipDuration properties
The toolTipDuration property controls how long the toolTip message is displayed in milliseconds. If set to -1, the display duration is determined by the length of the content in the toolTip.
StatusTip properties
The statusTip property saves statusTip information. When the mouse is placed over the control, the statusTip information is displayed in the status bar of the window. If the window has no status bar, the statusTip information is not displayed. The default value of the statusTip attribute is an empty string.
WhatsThis property
The whatsThis property holds help information for the component. The whatsThis help message is usually displayed after the component has gained focus by pressing Shift+F1. If this shortcut key is occupied by other functions, the whatsThis help message may not be displayed. Some dialog Windows provide a question mark button that can be clicked to display whatsThis help information. The whatsThis property defaults to an empty string.
AccessibleName properties
The accessibleName property is the name of the component displayed in assisted reading for disabled assisted reading. For most widgets, you don’t need to set this property because Qt invokes the display of component-specific properties, such as buttons that display the text of the button, but it is important when the widget doesn’t provide any text. For example, buttons that contain only ICONS need to have this property set for use with screen readers. This property defaults to null.
AccessibleDescription properties
The accessibleDescription property holds a description of the part as seen by assistive technology and is used for disabled reading. Adds to the accessibleName attribute. This property defaults to null.
LayoutDirection properties
The layoutDirection property stores the layoutDirection of the component and has three values:
- LeftToRight: layout from LeftToRight;
- RightToLeft: layout from RightToLeft;
- LayoutDirectionAuto: automatic layout.
AutoFillBackground properties
The autoFillBackground property verifies that the component background is automatically filled.
StyleSheet properties
The styleSheet property is an attribute styleSheet that defines the appearance of a component. In Qt, styleSheet is a method similar to CSS styles in HTML, but developed specifically for widgets in Qt. StyleSheet’s definition syntax is similar to CSS and is cross-platform.
Locale property
The locale attribute is used to set the locale, including the language and country. If a part has no locale set, either the parent object’s locale or the default locale is used (if the part is a top-level part).
WindowFilePath properties
The windowFilePath property applies only to window objects and is used to associate a window with the corresponding file and path. If the title property is not set, the title display displays information about the file name corresponding to windowFilePath (path information is not displayed). If both are set, the title property of the window is preferred as the title.
This property is empty by default and can be used to mark open files when a window opens them for operation.
InputMethodHints properties
The inputMethodHints property is only valid for input components, and input methods use it to retrieve hints about how input methods should operate. For example, if a flag is set to allow only numbers to be entered, an input method may change its visual components to reflect that only numbers can be entered. Related values and meanings are as follows:
- ImhNone: No hint;
- ImhHiddenText: input characters are not displayed;
- ImhSensitiveData: Input text is not stored in any persistent storage by the active input method;
- ImhNoAutoUppercase: Input method cannot automatically switch to uppercase at the end of a sentence;
- ImhPreferNumbers: number preferred (not required);
- ImhPreferUppercase: uppercase preferred (not required);
- ImhPreferLowercase: lowercase letters are preferred (not required);
- ImhNoPredictiveText: Input without predictive predictive text;
- ImhData: text editor for date field entry;
- ImhTime: text editor for time field input;
- ImhPreferLation: Latin characters are preferred (not required);
- ImhMultiLine: Multiple lines can be entered in a text field;
- ImhNoEditMenu: not applicable to built-in edit menu;
- ImhNoTextHandles: Do not use the built-in text cursor and select the operation mode;
- ImhDigitsOnly: numbers only allowed;
- LmhFormattedNumbersOnly: Only numbers (including decimal points and negative numbers) are allowed to be entered;
- LmhUppercaseOnly: only uppercase characters are allowed.
- LmhLowercaseOnly: Only lowercase characters are allowed.
- LmhDialableCharactersOnly: only allow input for telephone dial-up character;
- LmhEmailCharactersOnly: Only characters suitable for email addresses are allowed to be entered.
- LmhUrlCharactersOnly: Only characters suitable for the URL can be entered.
- LmhLatinOnly: Only Latin characters are allowed.
- LmhExclusivelnputMask: This mask is non-zero if any exclusive flags are used.
WindowModality properties
The windowModality property is only valid for window objects and stores what types of Windows are blocked by modal Windows. Modal Windows prevent widgets in other Windows from getting input. The value of this property controls which types of Windows are blocked for input when the corresponding window is visible. It is invalid to change this property while the mode window is visible. Related values and meanings are as follows:
- NonModal: A window is not a modal window;
- WindowModal: A window is a single-window hierarchy and prevents its parent window, all grandparent Windows, and all sibling Windows of its parent window and grandparent window from gaining access;
- ApplicationModal: A window is an application mode window that blocks all other application Windows from getting input.