Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. EnableHighDpiScaling does not affect font pixelSize or pointSize
QtWS25 Last Chance

EnableHighDpiScaling does not affect font pixelSize or pointSize

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.4k 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.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by
    #1

    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
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      K 1 Reply Last reply
      1
      • sierdzioS sierdzio

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

        K Offline
        K Offline
        Kofr
        wrote on last edited by Kofr
        #3

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

        • Login

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