当前位置:网站首页>布局管理中的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

总结的可能有点小问题,大家最好还是自己尝试一下
边栏推荐
- Qt开发高级进阶:初探qt + opengl
- 使用ubantu时,遇见的一些小毛病和解决方法
- The C programming language (version 2) notes / 8 UNIX system interface / 8.3 open, create, close, unlink
- Recommend 6 open source projects of yyds
- Idea how to set the guide package without * sign
- 博士申請 | 新加坡國立大學Xinchao Wang老師招收圖神經網絡方向博士/博後
- Cloud development kunkun chicken music box wechat applet source code
- su直接切换到超级管理员模式,这样很多报错都可以避免了
- Iscc-2022 part WP
- 大端模式和小端模式的区别
猜你喜欢

图片在线收款发货系统源码

redis. clients. jedis. exceptions. JedisConnectionException: Could not get a resource from the pool

Leetcode 2194. Cellules dans une plage dans un tableau Excel (OK, résolu)

Idea displays services on the console to uniformly manage all jetty services,

邱盛昌:OPPO商业化数据体系建设实战

5、Embedding

Google browser debugging skills

Programmers broke the news: 3 job hopping in 4 years, and the salary has tripled! Netizen: the fist is hard

如何查看、修改和删除SSH

D. master router setting and 401 networking
随机推荐
价值超高的CA证书解析
Object. Keys traverses an object
Sudo of uabntu
Modify the configuration of the router connected to your computer. The website is 192.168.1.1
Unit sshd. service could not be found
Uniapp壁纸小程序源码/双端微信抖音小程序源码
软件工程 学生信息管理系统 结构化的需求分析
PAT甲级 1139 第一次接触
STL——函数对象
token与幂等性问题
890. find and replace mode / Sword finger offer II 080 Combination with k elements
key为断言的map是怎么玩的
启牛开的证券账户安全吗?合法吗?
\Begin{algorithm} notes
Su directly switches to super administrator mode, so that many error reports can be avoided
About component value transfer
Golang recursively encrypts and decrypts all files under the specified folder
\begin{algorithm} 笔记
\begin{algorithm} 笔记
Qt开发高级进阶:初探qt + opengl