7

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?

jpnurmi
  • 5,716
  • 2
  • 21
  • 37
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267

3 Answers3

6

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.

jpnurmi
  • 5,716
  • 2
  • 21
  • 37
6

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

Jean-Michaël Celerier
  • 7,412
  • 3
  • 54
  • 75
2

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

Mamen abdou
  • 21
  • 1
  • 3