当前位置:网站首页>Qml 字体使用pixelSize来自适应界面
Qml 字体使用pixelSize来自适应界面
2022-07-07 23:53:00 【Fu_Lin_】
前言
一直被字体自适应这个问题困扰,尤其是使用pixelSize单位字体,在不同的分辨率电脑上会显示不一样的效果,有的大,有的中等,有的贼小,这是因为使用pixelSize会导致字体给固定住,多大就是大多,不会自己变化,遇到分辨率高的就变小,低的就贼大,刚好和设计原型差不多的,就看着很漂亮。
而使用pointSize虽然会自己放大缩小,但是和设计稿的字体差距很大,而且也会存在相应问题,而我更倾向于使用pixelSize
,既然它固定了,我可以根据比例自己放大缩小即可,所以本文重点就要解决的就是如何获取放大缩小的比例,使像素字体无论再什么设备上都能看起来是中等好看的!
思路
要想获取到字体的缩放因子,就得知道宽高的原始像素对比现设备的原始像素,分别得到不同的宽高比例值,获取最小值,这就是缩放比例因子,然后乘以当前的字体大小,就可以等比缩放字体了,当然还可以增加一个缩放基础因子,初始化为1,这个需要人为的调整,有的可能1不太好看,需要调整到1.1就会更佳,下面给出具体的获取代码
horizontalRatio = 变化的U
边栏推荐
- 2021-04-12 - new features lambda expression and function functional interface programming
- qt-使用自带的应用框架建立--hello world--使用min GW 32bit
- Deep learning website
- Redis master-slave replication
- The combination of relay and led small night light realizes the control of small night light cycle on and off
- common commands
- 用户之声 | 冬去春来,静待花开 ——浅谈GBase 8a学习感悟
- Kindle operation: transfer downloaded books and change book cover
- Content of one frame
- redis的持久化方式-RDB和AOF 两种持久化机制
猜你喜欢
4. Strategic Learning
STM32GPIO口的工作原理
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
解决报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Content of one frame
能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
Basic implementation of pie chart
On the concept and application of filtering in radar signal processing
The beauty of Mathematics -- the principle of fine Fourier transform
随机推荐
Matlab method is good~
2、TD+Learning
项目经理有必要考NPDP吗?我告诉你答案
用户之声 | 冬去春来,静待花开 ——浅谈GBase 8a学习感悟
QT--创建QT程序
从cmath文件看名字是怎样被添加到命名空间std中的
Understanding of prior probability, posterior probability and Bayesian formula
Common configurations in rectangular coordinate system
Leetcode notes No.7
break net
Kindle operation: transfer downloaded books and change book cover
Common effects of line chart
Transportation, new infrastructure and smart highway
Anaconda3 tutorial on installing and adding Tsinghua image files
Kaptcha generates verification code on Web page
Redis集群
2022 safety officer-a certificate free examination questions and safety officer-a certificate mock examination
2021 welder (primary) examination skills and welder (primary) operation examination question bank
2022 high altitude installation, maintenance and demolition examination materials and high altitude installation, maintenance and demolition operation certificate examination
The beauty of Mathematics -- the principle of fine Fourier transform