当前位置:网站首页>Qml 字体使用pixelSize来自适应界面
Qml 字体使用pixelSize来自适应界面
2022-07-07 23:53:00 【Fu_Lin_】
前言
一直被字体自适应这个问题困扰,尤其是使用pixelSize单位字体,在不同的分辨率电脑上会显示不一样的效果,有的大,有的中等,有的贼小,这是因为使用pixelSize会导致字体给固定住,多大就是大多,不会自己变化,遇到分辨率高的就变小,低的就贼大,刚好和设计原型差不多的,就看着很漂亮。
而使用pointSize虽然会自己放大缩小,但是和设计稿的字体差距很大,而且也会存在相应问题,而我更倾向于使用pixelSize,既然它固定了,我可以根据比例自己放大缩小即可,所以本文重点就要解决的就是如何获取放大缩小的比例,使像素字体无论再什么设备上都能看起来是中等好看的!
思路
要想获取到字体的缩放因子,就得知道宽高的原始像素对比现设备的原始像素,分别得到不同的宽高比例值,获取最小值,这就是缩放比例因子,然后乘以当前的字体大小,就可以等比缩放字体了,当然还可以增加一个缩放基础因子,初始化为1,这个需要人为的调整,有的可能1不太好看,需要调整到1.1就会更佳,下面给出具体的获取代码
horizontalRatio = 变化的U边栏推荐
- Redis 主从复制
- redis的持久化方式-RDB和AOF 两种持久化机制
- qt-使用自带的应用框架建立--hello world--使用min GW 32bit
- Kaptcha generates verification code on Web page
- Plot function drawing of MATLAB
- Running OFDM in gnuradio_ RX error: gr:: Log: info: packet_ headerparser_ b0 - Detected an invalid packet at item ××
- COMSOL - Construction of micro resistance beam model - final temperature distribution and deformation - establishment of geometric model
- General configuration toolbox
- 写一个纯手写的qt的hello world
- npm 内部拆分模块
猜你喜欢

break net

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

General configuration toolbox

Scalar / vector / matrix derivation method

如何让导电滑环信号更好

Qt - - Packaging Programs - - Don't install Qt - can run directly

从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值

2022 free test questions of fusion welding and thermal cutting and summary of fusion welding and thermal cutting examination

General configuration tooltip

About snake equation (2)
随机推荐
Getting started STM32 -- how to learn stm32
The usage of rand function in MATLAB
Common operations of numpy on two-dimensional array
4. Apprentissage stratégique
Qt - - Packaging Programs - - Don't install Qt - can run directly
How does Matplotlib generate multiple pictures in turn & only save these pictures without displaying them in the compiler
Scalar / vector / matrix derivation method
Frequency probability and Bayesian probability
3、多智能体强化学习
Plot function drawing of MATLAB
Application of state mode in JSF source code
正则表达式
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
How does Matplotlib and PIL image integrate and save multiple pictures into one picture
LaTeX 中 xcolor 颜色的用法
Apt get error
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
2021-03-06 - play with the application of reflection in the framework
Write a pure handwritten QT Hello World
Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings