当前位置:网站首页>Setup instance of layout manager login interface
Setup instance of layout manager login interface
2022-06-26 14:17:00 【Wind clearing】
The so-called graphical user interface (GUI ), It is essentially a stack of components . Create a window , Put the button on it , Put the icon on it , So it's an interface . therefore , The placement of components is particularly important , Specify where the component is placed , So that the window can be rendered in the desired way . This involves the mechanism of component localization .
Qt Two component localization mechanisms are provided : Absolute positioning and Layout orientation .
- Absolute positioning : Give the coordinates and length and width values of the components . such Qt You can know the location of components and set the size of components . But there's a problem : If user changes window size , For example, click the maximize button or drag the edge of the window with the mouse , Components with absolute positioning will not have any response . This is because I didn't tell Qt When the window changes , Whether the component wants to update itself and how .
- Layout orientation : Put components into a layout , The layout is managed by a dedicated layout manager . When you need to adjust the size or position ,Qt Use the corresponding layout manager to adjust .
Components with absolute positioning can prevent users from changing the window size to solve this problem , But this is also inappropriate . Layout positioning perfectly solves the defect caused by absolute positioning .
Qt The three most commonly used layouts provided :
- QHBoxLayout: Layout horizontally from left to right ;
- QVBoxLayout: Layout vertically from top to bottom ;
- QGridLayout: Lay out in a grid , Be similar to HTML Of table;
The layout control provided by the system
The system provides 4 A layout control , But it's not very flexible to use , I won't go into details here .

utilize widget Layout
The second layout is to use the widget To make the layout , stay Containers in

Can be in widget The control can be horizontally 、 vertical 、 Grid layout and other operations . Flexible use of the characteristics of the spring can make the step more beautiful , Here's a login window , utilize widget You can build the following login interface :

The following is a demonstration of the steps to build the login interface in the above figure :
- New project ——> open ui file :

- Break the layout , Otherwise, the control layout cannot be customized :

- add to label and line Edit:

- modify label after , Create a new one widget, And as shown in the figure, the label and line Edit All dragged in widget in , Then click grid layout :

- After clicking the grid layout , Will find widget Box size and labe The two controls do not match in size ,

It needs to be selected widget box , Set... In the property bar sizePOlicy The vertical strategy is fixed. The effect is as follows :


- Add two buttons , Double click to change to login and exit , Also create a new one widget, And drag both buttons into widget in , Then click grid layout . And select widget box , Set... In the property bar sizePOlicy The vertical strategy is fixed.:

- Choose the big one widget box , Set it to vertical layout ( This is an important step , Otherwise, adding springs in the next step will not work ) :

- Add spring , And set the width of the spring between some controls :

- The final effect is as follows :

Add
You can set the size of the login dialog to fixed in the dialog properties ( Just set the maximum and minimum to the same ). You can also set the input password box to secret input , Just check the password input box , Return the schema in the property echoMode Set to Password that will do .

边栏推荐
- Es common grammar I
- 虫子 STL string上
- Mathematical design D12 according to string function
- D中不用GC
- CVPR 2022文档图像分析与识别相关论文26篇汇集简介
- Educational Codeforces Round 117 (Rated for Div. 2)E. Messages
- 免费的机器学习数据集网站(6300+数据集)
- ArcGIS cannot be opened and displays' because afcore cannot be found ' DLL, solution to 'unable to execute code'
- Sword finger offer 10 Ⅰ 10Ⅱ. 63 dynamic planning (simple)
- [proteus simulation] Arduino uno key start / stop + PWM speed control DC motor speed
猜你喜欢

Gartner 2022 Top Strategic Technology Trends Report

Never use redis expired monitoring to implement scheduled tasks!

Included angle of 3D vector

Use performance to see what the browser is doing

Variable declaration of typescript

Sword finger offer 06.24.35 Linked list

Jenkins build prompt error: eacces: permission denied

程序员必备,一款让你提高工作效率N倍的神器uTools

Basic type of typescript

Free machine learning dataset website (6300+ dataset)
随机推荐
Stream常用操作以及原理探索
RISC-V 芯片架构新规范
7.consul service registration and discovery
Calculate the distance between two points (2D, 3D)
Reprint - easy to use wechat applet UI component library
Wechat applet - bind and prevent event bubble catch
免费的机器学习数据集网站(6300+数据集)
Educational Codeforces Round 117 (Rated for Div. 2)E. Messages
Jianzhi offer 43.47.46.48 dynamic planning (medium)
Sword finger offer 10 Ⅰ 10Ⅱ. 63 dynamic planning (simple)
FreeFileSync 文件夹比较与同步软件
使用 Performance 看看浏览器在做什么
A must for programmers, an artifact utools that can improve your work efficiency n times
Exercise set 1
Installation tutorial about origin2019
Linear basis count (k large XOR sum)
2021-10-18 character array
[scoi2016] lucky numbers
Basic type of typescript
Introduction to 26 papers related to CVPR 2022 document image analysis and recognition