当前位置:网站首页>layout manager
layout manager
2022-08-04 08:15:00 【Bitton】
The so-called GUI interface, in the final analysis, is the superposition of a bunch of components.We create a window, put buttons on it, put icons on it, and it becomes an interface.The location of the components is especially important when it comes to placement.We have to specify where to put the component so that the window can be rendered the way we want.This involves the mechanism of component positioning.
Qt provides two component positioning mechanisms: absolute positioning and layout positioning
Absolute positioning is one of the most primitive positioning methods: give the coordinates and length and width values of this component.
This way, Qt knows where to put the component and how to size it.But one problem with this is that if the user changes the size of the window, such as by clicking the maximize button or dragging the edge of the window with the mouse, absolutely positioned components will not respond.This is also natural, since you're not telling Qt whether and how the component should update itself when the window changes.Or, there is an easier way: prohibit the user from resizing the window.But this is not always the long-term solution.
Layout positioning: As long as components are placed in a layout, the layout is managed by a dedicated layout manager.When resizing or positioning is required, Qt uses the corresponding layout manager to adjust.
Layout positioning perfectly solves the defects of using absolute positioning.
The following three layouts provided by Qt are the most commonly used:
QHBoxLayout: Layout from left to right in the horizontal direction;
QVBoxLayout:Layout from top to bottom in the vertical direction;
QGridLayout: Layout in a grid, similar to HTML table.
1. System-provided layout controls

These 4 are the layouts provided by the systemControls, but not very flexible to use.
2. Use widgets for layout
The second layout method is to use the widget in the control to do the layout, in the Containers 
The controls in the widget can perform horizontal, vertical, grid layout and other operations, which are more flexible.
While re-layout, we need to flexibly use the characteristics of spring to make our layout more beautiful. The following is a login window. Using widgets, we can build the following login interface: 
边栏推荐
- 【论文笔记】Dynamic Convolution: Attention over Convolution Kernels
- 并查集介绍和基于并查集解决问题——LeetCode 952 按公因数计算最大组件大小
- Use of MotionLayout
- Redis分布式锁的应用
- New Questions in Module B of Secondary Vocational Network Security Competition
- 【CNN基础】转置卷积学习笔记
- form表单提交到数据库储存
- 【NOI模拟赛】纸老虎博弈(博弈论SG函数,长链剖分)
- LeetCode 135. 分发糖果
- 使用GBase 8c数据库的时候,遇到这种报错
猜你喜欢
随机推荐
GBase 8c数据库集群中,怎么替换节点呢?比如设置A节点为gtm,换到B节点上。
怎么写专利更容易通过?
从零开始C语言精讲篇6:结构体
Distributed Computing Experiment 4 Random Signal Analysis System
leetcode 22.7.31(1)两数之和 (2)整数除法
一天搞定JDBC02:开启事务
Distributed Computing Experiment 3 PRC-based Book Information Management System
金仓数据库KingbaseES客户端编程接口指南-JDBC(9. JDBC 读写分离)
通过GBase 8c Platform安装数据库集群时报错
LeetCode 135. 分发糖果
在安装GBase 8c数据库的时候,报错显示“Host ips belong to different cluster”。这是为什么呢?有什么解决办法?
高等代数_证明_幂等矩阵一定能够相似对角化
第一次用postgreSQL,想装主从,用的12.7 tar.gz版本。安装好后没在 share目录下找到样例配置recovery.conf.sample,是安装方式不对,还是路径不对?
技术实现 | 图像检索及其在淘宝的应用
LeetCode每日五题01:两数之和 (均1200题)
MYSQL JDBC图书管理系统
sql在字段重复时 对某个字段根据最新时间取数
24.循环神经网络RNN
金仓数据库KingbaseES客户端编程接口指南-JDBC(5. JDBC 查询结果集处理)
线程的状态









