Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85703

devicePixelRatio not correctly set on macOS with HDPI

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.13.2, 5.15.0
    • None
    • macOS

    Description

      It appears that devicePixelRatio is not correctly set for macOS. Same variable is set correctly for Linux and Windows when scaling is enabled but on macOS this variable is always 1 even though scaling is enabled.

       

      auto desktopWidget = QApplication::desktop();
       qDebug("DesktopWidget devicePixelRatio: %s", qPrintable(QString::number(desktopWidget->devicePixelRatio())));
       qDebug("DesktopWidget devicePixelRatioF: %s", qPrintable(QString::number(desktopWidget->devicePixelRatioF())));
       qDebug("DesktopWidget logicalDpiX: %s", qPrintable(QString::number(desktopWidget->logicalDpiX())));
       qDebug("DesktopWidget logicalDpiY: %s", qPrintable(QString::number(desktopWidget->logicalDpiY())));
       qDebug("DesktopWidget physicalDpiX: %s", qPrintable(QString::number(desktopWidget->physicalDpiX())));
       qDebug("DesktopWidget physicalDpiY: %s", qPrintable(QString::number(desktopWidget->physicalDpiY())));
      
       auto screen = QApplication::primaryScreen();
       qDebug("QScreen devicePixelRatio: %s", qPrintable(QString::number(screen->devicePixelRatio())));
       qDebug("QScreen logicalDotsPerInch: %s", qPrintable(QString::number(screen->logicalDotsPerInch())));
       qDebug("QScreen logicalDotsPerInchX: %s", qPrintable(QString::number(screen->logicalDotsPerInchX())));
       qDebug("QScreen logicalDotsPerInchY: %s", qPrintable(QString::number(screen->logicalDotsPerInchY())));
       qDebug("QScreen physicalDotsPerInch: %s", qPrintable(QString::number(screen->physicalDotsPerInch())));
       qDebug("QScreen physicalDotsPerInchX: %s", qPrintable(QString::number(screen->physicalDotsPerInchX())));
       qDebug("QScreen physicalDotsPerInchY: %s", qPrintable(QString::number(screen->physicalDotsPerInchY())));

       

      Gives following output:

      devicePixelRatio: 1
      devicePixelRatioF: 1
      logicalDpiX: 72
      logicalDpiY: 72 
      physicalDpiX: 114
      physicalDpiy: 114
      
      QScreen devicePixelRatio: 1
      QScreen logicalDotsPerInch: 72
      QScreen logicalDotsPerInchX: 72
      QScreen logicalDotsPerInchY: 72
      QScreen physicalDotsPerInch: 113.5
      QScreen physicalDotsPerInchX: 113.5
      QScreen physicalDotsPerInchY: 113.5
      

       

      Even though the macOS has a DPI of 227: "13-inch MacBook Pro models introduced in late 2012 or later. Native resolution: 2560 x 1600 at 227 pixels per inch. Support for millions of colors."

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            dporobic Damir Porobic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes