I would like to use native rendering for all the text in my application. For each Text
, Label
, etc. element I can do this
Text {
renderType: Text.NativeRendering
}
to trigger native rendering. I can also use the software renderer for the whole application:
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
However due to some bugs with the software renderer and some performance issues, I would like to avoid that.
Is there a global switch to change the render type?
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
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.
Add this line first in c++ main function : QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With