Qt World Summit: Submit your Presentation

How set Native text renderer globaly?

  • Hello,
    I trying to set native render globaly for my qml app. I tried to use QQuickWindow#setTextRenderType. But there is a problem, that method should be called before main.qml load otherwise it won't work at all (app will use Qt renderer). So i tried to load temporal file, then use setTextRenderType and then load main.qml, as i see it is not a good solution and it is looking bad. So any idea how can i do this in better way? There is a small example of main c++

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QQuickWindow>
    int main(int argc, char *argv[])
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        QQuickWindow* window = qobject_cast<QQuickWindow*>(engine.rootObjects().first());
        if (engine.rootObjects().isEmpty())
            return -1;
        return app.exec();


    import QtQuick 2.0
    Item { }


    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    ApplicationWindow {
        visible: true
        width: 300
        height: 300
        Label {
              anchors.centeIn: parent
              text: "Hello world!"

  • The QQuickWindow::setTextRenderType() is a static method and sets the application-wide default text rendering method. You can call it in C++ code before engine.load() or even before your QQmlApplicationEngine object is instantiated.