Blurred Qt Quick Text

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 an 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.


    This renders the font with native rendering. But not solves the problem with default Qt rendering.

    import QtQuick 2.4
    import QtQuick.Window 2.0
    
    Window {
        visible: true
        width: 512
        height: 300
    
        Text {
            anchors.centerIn: parent
            text: "Hello World!"
            renderType: Text.NativeRendering
        }
    }
    
    链接地址: http://www.djcxy.com/p/84524.html

    上一篇: orphanRemoval是否绕过了删除?

    下一篇: 模糊QT快速文本