当前位置:网站首页>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: 
边栏推荐
- How to write patents are more likely to pass?
- 在GBase 8c数据库后台,使用什么样的命令来对gtm、dn节点进行主备切换的操作?
- 25.时间序列预测实战
- 线程的状态
- 一天搞定JDBC01:连接数据库并执行sql语句
- Distributed Computing Experiment 2 Thread Pool
- 大佬们,mysql里text类型的字段,FlinkCDC需要特殊处理吗 就像处理bigint uns
- 【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
- GBase 8c数据库集群中,怎么替换节点呢?比如设置A节点为gtm,换到B节点上。
- 金仓数据库KingbaseES客户端编程接口指南-JDBC(6. JDBC 大对象数据处理)
猜你喜欢
随机推荐
怎么写专利更容易通过?
How to write patents are more likely to pass?
推荐几种可以直接翻译PDF英文文献的方法
布局管理器
Distributed Computing Experiment 2 Thread Pool
此时已莺飞草长,愿世间美好与你环环相扣
金仓数据库KingbaseES客户端编程接口指南-JDBC(5. JDBC 查询结果集处理)
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
Yolov5 replaces the backbone network of "Megvii Lightweight Convolutional Neural Network ShuffleNetv2"
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
并查集介绍和基于并查集解决问题——LeetCode 952 按公因数计算最大组件大小
一天学会JDBC03:Statement的用法
为什么手动启动GBase 8c数据库中GTM节点,起不来。显示“Run cmd failed:scp: /tmp/gtm_gtm1.server: Permission denied”
Typora颜色公式代码大全
阿里云的数据库系统怎么升级更新的www.zgysffm.com怎么加快访问速度?
关于常用状态码4XX提示错误
【电脑录制屏】如何使用bandicam录游戏 设置图文教程
安装GBase 8c数据库集群时,报错误码:80000306,显示Dcs cluster not healthy。怎么处理错误呢?
Interpretation of new features | MySQL 8.0 online adjustment REDO
「PHP基础知识」转换数据类型









