为什么Qt中的字体显得模糊或像素化? [英] Why fonts in Qt are appearing blurry or pixelated?

查看:1644
本文介绍了为什么Qt中的字体显得模糊或像素化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所有的字体都显示为像素化,因此我使用了AntiAliasing,但效果不佳.如您所见,图像本身具有像素化字体:

All my fonts are appearing pixelated, so I used AntiAliasing but it isn't helping out. As you can see the pixelated font in the image itself:

这是我当前正在使用的代码:

This is the code I am currently using:

butt1 = QtWidgets.QLabel("""Scrappr""")
font = QtGui.QFont()
font.setStyleStrategy(QtGui.QFont.PreferAntialias)
font.setPixelSize(22)
font.setFamily('Segoe UI Bold')
butt1.setFont(QtGui.QFont(font))

我在SO,qtforums等上尝试了不同的解决方案,但对我没有任何帮助:(

I tried different solutions on SO, qtforums etc but nothing works for me :(

我尝试过:

  • ClearType text的不同组合,但无法解决,因为默认情况下,所有文本在Windows和Chrome上显示良好,但 仅在Qt上显示为像素化.

  • Different combinations of ClearType text but It didn't work out as, by default all the text appears good on windows and chrome but with Qt only, it becomes pixelated.

正在将Windows Aero主题更改为经典主题...

Changing windows aero theme to classic one...

但是他们都没有帮助.

这是我的PC规格:

  • windows:7旗舰版
  • PySide2版本:5.14.2.1
  • 分辨率:1360 X 768

推荐答案

去年我碰巧与Qt一起工作,并且我使用qml来构建应用程序的UI部分.

I happen to work with Qt last year and i used qml for building the UI part of my application.

Qt本身更喜欢我们使用qml来构建UI,因为他们编写了一个UI引擎,与旧引擎相比,它可以使所有内容呈现得更好.

Qt itself prefers us to use qml for building UI, since they have written a UI engine that renders everything better compared to the old engines.

对于PyQt,您使用的是通常不建议使用的仅python方法,我并不是说qml版本是像素完美的.它仍然无法绘制曲线(但这不是我们通常需要的东西).就您的问题而言,qml可以很好地为您工作(它具有更好的文本呈现功能).

In case of PyQt you are using the python only approach which is only not usually recommended, i am not saying that the qml version is pixel perfect. it still works bad at drawing curves (but that is not the stuff we usually require). As far as your problem is concerned qml will work fine for you (it has much better text rendering).

您可能会很难找到qml的学习资源.但是至少可以试一下,是的,它比仅使用Python的方法容易得多.

You might struggle a bit finding the learning resource for qml. But at least give it a shot and yes it is easier much easier than Python only approach.

这篇关于为什么Qt中的字体显得模糊或像素化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆