当前位置:网站首页>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:
边栏推荐
猜你喜欢
leetcode 22.7.31(1)两数之和 (2)整数除法
IntelliJ新建一个类或者包的快捷键是什么?
【论文笔记】Dynamic Convolution: Attention over Convolution Kernels
从零开始C语言精讲篇6:结构体
华为设备配置VRRP与路由联动监视上行链路
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
微信消息从发送到接收,经历了什么?如何防止丢包
IDEA引入类报错:“The file size (2.59 MB) exceeds the configured limit (2.56MB)
使用腾讯云发送短信 ---- 手把手教你搞定所有步骤
【CNN基础】转置卷积学习笔记
随机推荐
MySQL group_concat()详解
解决:Hbuilder工具点击发行打包,一直报尚未完成社区身份验证,请点击链接xxxxx,项目xxx发布H5失败的错误。
使用单调栈解决接雨水问题——LeetCode 42 接雨水+单调栈说明
LeetCode每日五题01:两数之和 (均1200题)
【STM32】STM32F103系列名称与封装、内存
binder通信实现
ConstraintSet of animation of ContrstrainLayout
【我想要老婆】
为什么手动启动GBase 8c数据库中GTM节点,起不来。显示“Run cmd failed:scp: /tmp/gtm_gtm1.server: Permission denied”
redis分布式锁的实现
线程和进程之间的区别
一天搞定JDBC02:开启事务
微信消息从发送到接收,经历了什么?如何防止丢包
The difference between character stream and byte stream
大家好,请教一个问题啊,我们通过flinkcdc把Oracle数据同步到doris,目前的问题是,只
高等代数_证明_对称矩阵属于不同特征值的特征向量正交
unittest使用简述
1161. Maximum Level Sum of a Binary Tree
Thread类的基本使用。
GBase 8c中怎么查询数据库配置参数,例如datestyle。使用什么函数或者语法呢?