Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved EnableHighDpiScaling does not affect font pixelSize or pointSize

    QML and Qt Quick
    2
    3
    1160
    Loading More Posts
    • 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.
    • K
      Kofr last edited by

      According to documentation 'Qt::AA_EnableHighDpiScaling' , introduced in Qt 5.6, enables automatic scaling based on the pixel density of the monitor.
      Shall scale all sizes in screen. However it does not affect qml Text component's font.pixelSize or font.pointSize
      How to scale text properly? What technics do I need to use to scale fonts?

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Try using Label component instead. And remember that flag only works with QtQuick.Controls 2.

        (Z(:^

        K 1 Reply Last reply Reply Quote 1
        • K
          Kofr @sierdzio last edited by Kofr

          @sierdzio this flag works for all coordinates, not only for Controls 2 components.
          Label behaves the same Way as Text.

          qreal refDpi = 216.;
          qreal refHeight = 1776.;
          qreal refWidth = 1080.;
          QRect rect = QGuiApplication::primaryScreen()->geometry();
          qreal height = qMax(rect.width(), rect.height());
          qreal width = qMin(rect.width(), rect.height());
          qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch();
          m_ratio = qMin(height/refHeight, width/refWidth);
          m_ratioFont = qMin(height*refDpi/(dpi*refHeight), width*refDpi/(dpi*refWidth));
          

          formula from https://doc.qt.io/qt-5/scalability.html does not work for text scaling for me
          Does anybody have solution which works for Android and iOs for text scaling at same time?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post