当前位置:网站首页>布局管理中的sizePolicy的策略问题
布局管理中的sizePolicy的策略问题
2022-06-12 16:55:00 【yinchengkai】
一、sizeHint值是啥?
每一个部件拖放到窗口上的时候,都会有一个默认的sizeHint的尺寸大小值(顶层窗口返回的sizeHint值为(-1,-1) ),同一种部件在布局管理器中和不在管理器中的sizeHint的大小是不一样的,但是我们打印发现,布局中的部件pushbutton_1实际size既不是sizeHint的默认值也不是没有拖进布局之前的设置的size,而是参考sizeHint之后得到的值;pushbutton_3的size大小为我们拖进来设置的大小,没有使用sizeHint的值
qDebug()<<"pushButton_1:"<<"sizeHint"<<ui->pushButton_1->sizeHint()<<"size:"<<ui->pushButton_1->size();
qDebug()<<"pushButton_2:"<<"sizeHint"<<ui->pushButton_2->sizeHint()<<"size:"<<ui->pushButton_2->size();
qDebug()<<"pushButton_3:"<<"sizeHint"<<ui->pushButton_3->sizeHint()<<"size:"<<ui->pushButton_3->size();打印结果如下所示,可见布局中的尺寸只是参考了sizeHint的值,并没有和它相同;没有布局的pushbutton__3的尺寸为我们拖进来时候geometry属性中的大小:
pushButton_1: sizeHint QSize(97, 28) size: QSize(100, 30)
pushButton_2: sizeHint QSize(97, 28) size: QSize(100, 30)
pushButton_3: sizeHint QSize(105, 28) size: QSize(251, 29)

二、sizePolicy的各种策略
1.Fixed

2.Minimum

3.Maximum

总结的可能有点小问题,大家最好还是自己尝试一下
边栏推荐
- \begin{algorithm} 笔记
- 软件工程 学生信息管理系统 结构化的需求分析
- What's the matter with pbootcms' if judgment failure and direct display of labels?
- Unit sshd. service could not be found
- (五)输出和输出
- 云开发坤坤鸡乐盒微信小程序源码
- 丁总路由器设置以及401联网
- Large scale real-time quantile calculation -- a brief history of quantitative sketches
- Recommend 6 open source projects of yyds
- Swin transformer code explanation
猜你喜欢

Google browser debugging skills

Leetcode 2190. 数组中紧跟 key 之后出现最频繁的数字(可以,一次过)

Large scale real-time quantile calculation -- a brief history of quantitative sketches

2080 virtual machine login command

Google浏览器调试技巧
![[research] reading English papers -- the welfare of researchers in English poor](/img/8a/671e6cb6a3f4e3b84ea0795dc5a365.png)
[research] reading English papers -- the welfare of researchers in English poor

程序员爆料:4年3次跳槽,薪资翻了3倍!网友:拳头硬了......

从50亿图文中提取中文跨模态新基准Zero,奇虎360全新预训练框架超越多项SOTA

MongoDB 学习整理(用户,数据库,集合,文档 的基础命令学习)
![[Hunan University] information sharing of the first and second postgraduate entrance examinations](/img/15/298ea6f7367741e1e085007c498e51.jpg)
[Hunan University] information sharing of the first and second postgraduate entrance examinations
随机推荐
[Hunan University] information sharing of the first and second postgraduate entrance examinations
Loading shellcode in C and go languages
redis. clients. jedis. exceptions. JedisConnectionException: Could not get a resource from the pool
\begin{algorithm} 笔记
Possible problems of long jump in gaussdb
快速入门scrapy爬虫框架
Gerrit+2触发Jenkins任务
CVPR 2022 | meta learning performance in image regression task
男神女神投票源码 v5.5.21 投票源码
Download PHP source code of leaf sharing station
C # final review programming question (guessed by the teacher)
QCustomplot笔记(一)之QCustomplot添加数据以及曲线
CVPR 2022 | 元学习在图像回归任务的表现
Canvas advanced functions (Part 2)
redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required
(七)循环语句for
使用GCC的PGO(Profile-guided Optimization)优化整个系统
The safety of link 01 was questioned, and "ultra high strength" became "high strength"_ Publicity_ Steel_ problem
Iscc-2022 part WP
selenium元素定位