Can I globally switch to native text rendering in Qt Quick Controls 2?

Since Qt 5.7, you can change the default Qt Quick text render type, but unfortunately only at build time. In order to change the default, you would have to rebuild libQt5Quick.so with QT_QUICK_DEFAULT_TEXT_RENDER_TYPE set to NativeRendering. For more details, see https://codereview.qt-project.org/#/c/121748/ .

If you have installed Qt using an installer from qt.io, install the source packages using the maintenance tool if you already haven't done so, navigate to qtdeclarative/src/quick, run qmake with the define, and build. Something along the lines:

cd path/to/Qt/Sources/5.8/qtdeclarative/src/quick
# NOTE: make sure to run qmake from the same/correct Qt installation
path/to/Qt/5.8/<spec>/qmake "DEFINES+=QT_QUICK_DEFAULT_TEXT_RENDER_TYPE=NativeRendering"
make -jN

If you have a self-built Qt installation, invoke make clean (or if you want to save time, just delete qquicktext*.o) before make to rebuild the library.

EDIT: Since Qt 5.10, it is also possible to specify the default text render type in C++ via QQuickWindow::setTextRenderType(). Just notice to set it before loading the QML content.


The environment variable QML_DISABLE_DISTANCEFIELD controls this. If you put

qputenv("QML_DISABLE_DISTANCEFIELD", "1");

at the beginning of your main, you will get a nice and sharp text rendering everywhere.

Source: http://www.kdab.com/~thomas/stuff/distancefield.html


Add this line first in c++ main function : QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);