Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How set Native text renderer globaly?
QtWS25 Last Chance

How set Native text renderer globaly?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmlc++text renderingnative renderinwin
7 Posts 4 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hvorovk
    wrote on last edited by
    #1

    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[])
    {
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
    
        engine.load(QUrl(QStringLiteral("qrc:/qml/tempItem.qml")));
        QQuickWindow* window = qobject_cast<QQuickWindow*>(engine.rootObjects().first());
        window->setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
        engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
    
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    

    tempItem.qml

    import QtQuick 2.0
    Item { }
    

    main.qml

    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!"
        }
    }
    
    1 Reply Last reply
    0
    • martin_kyM Offline
      martin_kyM Offline
      martin_ky
      wrote on last edited by
      #2

      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.

      RokeJulianLockhartR 1 Reply Last reply
      0
      • martin_kyM martin_ky

        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.

        RokeJulianLockhartR Offline
        RokeJulianLockhartR Offline
        RokeJulianLockhart
        wrote on last edited by
        #3

        @martin_ky, do you know how to invoke that via python3 (with PyQt6 or PySide6)? If not, do you know where that information might be available...? https://stackoverflow.com/questions/43369016/can-i-globally-switch-to-native-text-rendering-in-qt-quick-controls-2 doesn't help much.

        When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

        RokeJulianLockhartR 1 Reply Last reply
        0
        • RokeJulianLockhartR RokeJulianLockhart

          @martin_ky, do you know how to invoke that via python3 (with PyQt6 or PySide6)? If not, do you know where that information might be available...? https://stackoverflow.com/questions/43369016/can-i-globally-switch-to-native-text-rendering-in-qt-quick-controls-2 doesn't help much.

          RokeJulianLockhartR Offline
          RokeJulianLockhartR Offline
          RokeJulianLockhart
          wrote on last edited by RokeJulianLockhart
          #4

          https://discuss.kde.org/t/qml-pyqt6-cant-get-native-control-appearance/1240/10?u=rokejulianlockhart

          it the solution. How to mark this as solved?

          When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

          SGaistS 1 Reply Last reply
          0
          • RokeJulianLockhartR RokeJulianLockhart

            https://discuss.kde.org/t/qml-pyqt6-cant-get-native-control-appearance/1240/10?u=rokejulianlockhart

            it the solution. How to mark this as solved?

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @BEEDELL-ROKE-JULIAN-LOCKHART hi, you can use the "Topic Tools" button or the three doted menu beside the answer your deem correct.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            RokeJulianLockhartR 1 Reply Last reply
            0
            • SGaistS SGaist

              @BEEDELL-ROKE-JULIAN-LOCKHART hi, you can use the "Topic Tools" button or the three doted menu beside the answer your deem correct.

              RokeJulianLockhartR Offline
              RokeJulianLockhartR Offline
              RokeJulianLockhart
              wrote on last edited by
              #6

              @SGaist, a9db0ecd-34ad-4a75-870f-d045a83f51ff-image.png

              I don't see it.

              When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

              SGaistS 1 Reply Last reply
              0
              • RokeJulianLockhartR RokeJulianLockhart

                @SGaist, a9db0ecd-34ad-4a75-870f-d045a83f51ff-image.png

                I don't see it.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @BEEDELL-ROKE-JULIAN-LOCKHART my bad, I did not saw that you were not the thread author. As such you cannot mark it solved.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved