当前位置:网站首页>Qml 字体使用pixelSize来自适应界面
Qml 字体使用pixelSize来自适应界面
2022-07-07 23:53:00 【Fu_Lin_】
前言
一直被字体自适应这个问题困扰,尤其是使用pixelSize单位字体,在不同的分辨率电脑上会显示不一样的效果,有的大,有的中等,有的贼小,这是因为使用pixelSize会导致字体给固定住,多大就是大多,不会自己变化,遇到分辨率高的就变小,低的就贼大,刚好和设计原型差不多的,就看着很漂亮。
而使用pointSize虽然会自己放大缩小,但是和设计稿的字体差距很大,而且也会存在相应问题,而我更倾向于使用pixelSize,既然它固定了,我可以根据比例自己放大缩小即可,所以本文重点就要解决的就是如何获取放大缩小的比例,使像素字体无论再什么设备上都能看起来是中等好看的!
思路
要想获取到字体的缩放因子,就得知道宽高的原始像素对比现设备的原始像素,分别得到不同的宽高比例值,获取最小值,这就是缩放比例因子,然后乘以当前的字体大小,就可以等比缩放字体了,当然还可以增加一个缩放基础因子,初始化为1,这个需要人为的调整,有的可能1不太好看,需要调整到1.1就会更佳,下面给出具体的获取代码
horizontalRatio = 变化的U边栏推荐
- Connect to the previous chapter of the circuit to improve the material draft
- Common fault analysis and Countermeasures of using MySQL in go language
- LaTeX 中 xcolor 颜色的用法
- Working principle of stm32gpio port
- npm 內部拆分模塊
- 2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
- How does Matplotlib generate multiple pictures in turn & only save these pictures without displaying them in the compiler
- Gnuradio3.9.4 create OOT module instances
- Usage of xcolor color in latex
- 能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
猜你喜欢

Write a pure handwritten QT Hello World

Different methods for setting headers of different pages in word (the same for footer and page number)

用户之声 | 冬去春来,静待花开 ——浅谈GBase 8a学习感悟

4. Apprentissage stratégique
![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

2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions

5、离散控制与连续控制

QT--创建QT程序

2022 high altitude installation, maintenance and demolition examination materials and high altitude installation, maintenance and demolition operation certificate examination

从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
随机推荐
The communication clock (electronic time-frequency or electronic time-frequency auxiliary device) writes something casually
After modifying the background of jupyter notebook and adding jupyterthemes, enter 'JT -l' and the error 'JT' is not an internal or external command, nor a runnable program
The beauty of Mathematics -- the principle of fine Fourier transform
Matlab code on error analysis (MAE, MAPE, RMSE)
STM32GPIO口的工作原理
The difference between distribution function and probability density function of random variables
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
5、離散控制與連續控制
Grey correlation analysis link (portal) matlab
子矩阵的和
Leetcode exercise - Sword finger offer 36 Binary search tree and bidirectional linked list
About snake equation (5)
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况----几何模型的建立
Different methods for setting headers of different pages in word (the same for footer and page number)
Is it safe to open an account on your mobile phone for small amount of stock speculation?
跨模态语义关联对齐检索-图像文本匹配(Image-Text Matching)
Introduction to natural language processing (NLP) based on transformers
qt-使用自带的应用框架建立--hello world--使用min GW 32bit
2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
qt--将程序打包--不要安装qt-可以直接运行