当前位置:网站首页>Qml 字体使用pixelSize来自适应界面
Qml 字体使用pixelSize来自适应界面
2022-07-07 23:53:00 【Fu_Lin_】
前言
一直被字体自适应这个问题困扰,尤其是使用pixelSize单位字体,在不同的分辨率电脑上会显示不一样的效果,有的大,有的中等,有的贼小,这是因为使用pixelSize会导致字体给固定住,多大就是大多,不会自己变化,遇到分辨率高的就变小,低的就贼大,刚好和设计原型差不多的,就看着很漂亮。
而使用pointSize虽然会自己放大缩小,但是和设计稿的字体差距很大,而且也会存在相应问题,而我更倾向于使用pixelSize,既然它固定了,我可以根据比例自己放大缩小即可,所以本文重点就要解决的就是如何获取放大缩小的比例,使像素字体无论再什么设备上都能看起来是中等好看的!
思路
要想获取到字体的缩放因子,就得知道宽高的原始像素对比现设备的原始像素,分别得到不同的宽高比例值,获取最小值,这就是缩放比例因子,然后乘以当前的字体大小,就可以等比缩放字体了,当然还可以增加一个缩放基础因子,初始化为1,这个需要人为的调整,有的可能1不太好看,需要调整到1.1就会更佳,下面给出具体的获取代码
horizontalRatio = 变化的U边栏推荐
- [loss function] entropy / relative entropy / cross entropy
- qt-使用自带的应用框架建立--hello world--使用min GW 32bit
- NPDP在国内有认可度吗?看一看就明白了!
- Tapdata 的 2.0 版 ,開源的 Live Data Platform 現已發布
- Frequency probability and Bayesian probability
- 解决报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
- Basic realization of line chart (II)
- Common effects of line chart
- 2022 safety officer-b certificate examination question bank and safety officer-b certificate simulation test questions
- Four digit nixie tube display multi digit timing
猜你喜欢

Js中forEach map无法跳出循环问题以及forEach会不会修改原数组

The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1

COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况---材料的添加

COMSOL - Construction of micro resistance beam model - final temperature distribution and deformation - establishment of geometric model

Transportation, new infrastructure and smart highway

ArrayList源码深度剖析,从最基本的扩容原理,到魔幻的迭代器和fast-fail机制,你想要的这都有!!!

2022 new examination questions for crane driver (limited to bridge crane) and question bank for crane driver (limited to bridge crane) operation examination

Talk about smart Park

LeetCode 练习——剑指 Offer 36. 二叉搜索树与双向链表
![Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small](/img/ab/066923f1aa1e8dd8dcc572cb60a25d.jpg)
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
随机推荐
碳刷滑环在发电机中的作用
A little experience from reading "civilization, modernization, value investment and China"
Frequency probability and Bayesian probability
Common configurations in rectangular coordinate system
Common operations of numpy on two-dimensional array
Matlab method is good~
2021 tea master (primary) examination materials and tea master (primary) simulation test questions
3、多智能体强化学习
5. Contrôle discret et contrôle continu
Scalar / vector / matrix derivation method
Application of state mode in JSF source code
能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
3. Multi agent reinforcement learning
The examination contents of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge) in 2021 and the free examination questions of the third batch of Guangdong Prov
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds
Kaptcha generates verification code on Web page
如何让导电滑环信号更好
项目经理有必要考NPDP吗?我告诉你答案
从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
Usage of xcolor color in latex