当前位置: 首页 > news >正文

Qt-QSplitter正确设置比例

简短版本:

splitter->setSizes({1000, 2000}); // 这个值至少跟像素值设置的一样大,或者更大,例如x10倍

详细版本:
setSizes 官方介绍如下:

Sets the child widgets’ respective sizes to the values given in the list.
If the splitter is horizontal, the values set the width of each widget in pixels, from left to right. If the splitter is vertical, the height of each widget is set, from top to bottom.
Extra values in the list are ignored. If list contains too few values, the result is undefined, but the program will still be well-behaved.
The overall size of the splitter widget is not affected. Instead, any additional/missing space is distributed amongst the widgets according to the relative weight of the sizes.
If you specify a size of 0, the widget will be invisible. The size policies of the widgets are preserved. That is, a value smaller than the minimal size hint of the respective widget will be replaced by the value of the hint.

重点如下:

splitter大小不会变化,比设置的值多的和少的空间将会按照sizes之间的比例分配
size policy保留,且widget至少有minmum size的最小值大小

网上说的setStetch方法对我不管用(左边使用QTreeWidget,右边是QWidget),并且会受到sizePolicy和minimum size影响,因此我并不推荐使用。

http://www.lryc.cn/news/253188.html

相关文章:

  • 一篇吃透大厂面试题,2024找工作一帆风顺。
  • 【1day】用友 U8 Cloud系统TaskTreeQuery接口SQL注入漏洞学习
  • 华为快应用中自定义Slider效果
  • C语言每日一题(43)旋转链表
  • CCF计算机软件能力认证考试—202209-1如此编码
  • Ubuntu18.04安装Ipopt-3.12.8流程
  • linux 内核同步互斥技术之信号量
  • 交通强国添力量 无人机巡航为何备受期待?
  • 【PID学习笔记 6 】控制系统的性能指标之二
  • ZLMediakit-method ANNOUNCE failed: 401 Unauthorized(ffmpeg、obs推流rtmp到ZLM发现的问题)
  • 聊聊logback的ThrowableProxyConverter
  • Kubernetes(k8s)访问不了Pod服务
  • python-学生管理|汉罗塔
  • python 堆与栈
  • 园区规划技术要点
  • 深入浅出 Linux 中的 ARM IOMMU SMMU III
  • Linux系统---图书管理中的同步问题
  • Vue学习笔记-activated和deactivated生命周期
  • 102.套接字-Socket网络编程4(TCP通信流程)
  • spring boot 2 升级到 spring boot 3 后文件上传失败
  • Java Stream API 提供了一种非常方便的方式来比较两个 List 的差异,并取出不同的对象
  • C语言还会存在多久
  • 手持式安卓主板_PDA安卓板_智能手持终端方案
  • LeetCode103. Binary Tree Zigzag Level Order Traversal
  • PHP 判断给定两个时间是否在同一周,月,年
  • 单机无锁线程安全队列-Disruptor
  • 好工具知多少:国内外最常用的SCADA软件
  • SQL Server 2016(创建数据库)
  • Vue学习计划--Vue2(一)简单了解vue
  • 微信小程序生成二维码并保存到本地方法