本文介绍了如何在高DPI屏幕上的Qt 5.6中再次使svg图标清晰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从Qt 5.4升级到Qt 5.6使我的所有.svg图标变得模糊/像素化.我注意到这种情况仅发生在像MacBookPro Retina Display这样的高密度屏幕上.我阅读了Qt 5.6中高DPI支持的文档,并且已经将QT_AUTO_SCREEN_SCALE_FACTOR=1
环境变量,但效果不大.有人遇到这个问题吗?我还发现了此错误报告,该错误报告可能与我的问题有关.
Upgrading from Qt 5.4 to Qt 5.6 made all my .svg icons blurry/pixelated. I noticed this happens only on high density screens like on my MacBookPro Retina Display. I read the documentation of High DPI support in Qt 5.6 and I have set the QT_AUTO_SCREEN_SCALE_FACTOR=1
environment variable, but it didn't have much effect. Anybody has this issue? I have also found this bug report which probably relates to my question.
一个简单的例子是:
Image {
source: my_icon.svg
sourceSize.width: 50
sourceSize.height: 50
anchor.centerIn: parent
}
推荐答案
这是一个丑陋的骇客,但确实成功了:
This is an ugly hack, but it did the trick:
Item {
property alias image: mySvgImage
implicitWidth: mySvgImage.paintedWidth
implicitHeight: mySvgImage.implicitHeight / Screen.devicePixelRatio
Image {
id: mySvgImage
sourceSize.width: width * Screen.devicePixelRatio
sourceSize.height: height * Screen.devicePixelRatio
}
}
这篇关于如何在高DPI屏幕上的Qt 5.6中再次使svg图标清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!