模糊的 Qt 快速文本 [英] Blurred Qt Quick Text

查看:27
本文介绍了模糊的 Qt 快速文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是来自 Qt Creator 中的 Qt Quick 示例的示例,当我运行该项目时,所有文本都失去了质量并变得模糊,附图清楚地描述了问题.

Qt 版本:5.4.1

平台:Windows 7

解决方案

Qt 使用系统 OpenGL 能力时可能会在某些硬件上重现的老 bug "[QTBUG-31983] Windows XP 上的字体渲染显示带有 QML Text 元素的工件"

在 Qt 5.5 版之前,有两种用于 Windows 的 Qt 版本:ANGLE 和 OpenGL.它们可以通过安装程序文件名中的后缀opengl"来区分,例如:

qt-opensource-windows-x86-msvc2013_opengl-5.4.1.exeqt-opensource-windows-x86-msvc2013-5.4.1.exe

请参阅 "Qt 5 on Windows ANGLE 和 OpenGL" 了解说明.

ANGLE 版本没有这样的缺陷.只有 OpenGL 构建受到影响.默认情况下,许多 Windows 安装对 OpenGL 的支持很差.在某些情况下,它可能会在 QML 窗口初始化期间崩溃.需要手动安装视频驱动程序.但是,对于一些老硬件来说,要找到这么好的显卡驱动来支持OpenGL是一个问题.

可能的解决方案:

  • 使用 ANGLE Qt 构建
  • 可以使用默认渲染类型 Text.NativeRendering 子类化标准 QML Text 控件:
<块引用>

Text { renderType: Text.NativeRendering;}

如果不支持 Windows XP,ANGLE Qt 构建可能是一个很好的解决方案.

如果不需要大量使用图形,更好的解决方案是使用软件 OpenGL 渲染.在 Qt 5.4 之前,可以使用 MSYS Mesa 库 opengl32.dll(只能使用某些特定版本).如果将此类库放置在使用 OpenGL Qt 版本构建的 Qt 应用程序的可执行文件夹中,则该库将自动用于软件渲染,而不是默认的硬件渲染.从 Qt 5.4 开始,此类库由 Qt 提供:opengl32sw.dll (http://doc.qt.io/qt-5/windows-requirements.html).

软件 OpenGL 模拟在所有类型的硬件上都能完美运行,并且不需要任何特殊的显卡驱动程序.

从 Qt 5.4 开始,应用程序属性 Qt::AA_UseSoftwareOpenGL:

<块引用>

强制使用基于软件的 OpenGL 实现使用 OpenGL 实现的动态加载的平台.这通常是 Mesa llvmpipe 的修补版本,提供 OpenGL2.1.如果没有这样的 OpenGL 实现可用,则该值可能无效.这个库的默认名称是opengl32sw.dll,可以通过设置环境变量 QT_OPENGL_DLL 来覆盖.看特定于平台的页面,例如 Qt for Windows,了解更多信息.此值已在 Qt 5.4 中添加.

This is an example from Qt Quick examples inside Qt Creator, when I run the project all texts lost their quality and blurred, the attached picture describes clearly the problem.

Qt Version: 5.4.1

Platform: Windows 7

解决方案

It is an old bug that may be reproduced on some hardware when Qt uses system OpenGL capabilities "[QTBUG-31983] Font rendering on Windows XP shows artifacts with QML Text element"

Before Qt version 5.5 there are two types of Qt releases for Windows: ANGLE and OpenGL. They can be distinguished by the suffix "opengl" in the installer file name, for example:

qt-opensource-windows-x86-msvc2013_opengl-5.4.1.exe
qt-opensource-windows-x86-msvc2013-5.4.1.exe

See "Qt 5 on Windows ANGLE and OpenGL" for the explanation.

The ANGLE build does not have such defect. Only OpenGL build is affected. OpenGL is poorly supported by default on many Windows installations. In some cases it can just crash during QML window initialization. The manual video driver installation was required. However, for some old hardware it is a problem to find such good video card driver that have enough support for OpenGL.

Possible solutions:

  • Use ANGLE Qt build
  • It is possible to subclass the standard QML Text control with default render type Text.NativeRendering:

Text { renderType: Text.NativeRendering; }

ANGLE Qt build could be a good solution if Windows XP should not be supported.

If no intensive graphics usage is required the better solution is to use software OpenGL rendering. Before Qt 5.4 it is was possible to use MSYS Mesa library opengl32.dll (only some specific version should be used). If such library is placed in the executable folder of Qt application built with OpenGL Qt version, that library is automatically used for software rendering instead of default hardware rendering. Starting from Qt 5.4 such library is provided by Qt: opengl32sw.dll (http://doc.qt.io/qt-5/windows-requirements.html).

The software OpenGL emulation works perfectly on all types of hardware and it does not require any special video card driver.

Starting from Qt 5.4 there is the application attribute Qt::AA_UseSoftwareOpenGL:

Forces the usage of a software based OpenGL implementation on platforms that use dynamic loading of the OpenGL implementation. This will typically be a patched build of Mesa llvmpipe, providing OpenGL 2.1. The value may have no effect if no such OpenGL implementation is available. The default name of this library is opengl32sw.dll and can be overridden by setting the environment variable QT_OPENGL_DLL. See the platform-specific pages, for instance Qt for Windows, for more information. This value has been added in Qt 5.4.

这篇关于模糊的 Qt 快速文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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