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?
Forum Updated to NodeBB v4.3 + New Features

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 2 Watching
  • 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 23 May 2020, 01:51 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
    • M Offline
      M Offline
      martin_ky
      wrote on 21 Oct 2020, 10:45 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.

      R 1 Reply Last reply 1 May 2023, 13:16
      0
      • M martin_ky
        21 Oct 2020, 10:45

        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.

        R Offline
        R Offline
        RokeJulianLockhart
        wrote on 1 May 2023, 13:16 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.

        R 1 Reply Last reply 2 May 2023, 16:36
        0
        • R RokeJulianLockhart
          1 May 2023, 13:16

          @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.

          R Offline
          R Offline
          RokeJulianLockhart
          wrote on 2 May 2023, 16:36 last edited by RokeJulianLockhart 5 Feb 2023, 16:37
          #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.

          S 1 Reply Last reply 2 May 2023, 18:26
          0
          • R RokeJulianLockhart
            2 May 2023, 16:36

            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?

            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 2 May 2023, 18:26 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

            R 1 Reply Last reply 2 May 2023, 18:31
            0
            • S SGaist
              2 May 2023, 18:26

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

              R Offline
              R Offline
              RokeJulianLockhart
              wrote on 2 May 2023, 18:31 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.

              S 1 Reply Last reply 2 May 2023, 18:32
              0
              • R RokeJulianLockhart
                2 May 2023, 18:31

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

                I don't see it.

                S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 2 May 2023, 18:32 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