2

I'm working on a cross platform application for Linux, Windows and macOS and there is part where I need to scale something based on the screen scaling. So far I have been using QApplication::desktop()->devicePixelRatioF() under Linux and Windows to get the scale factor and that works fine but now one of my users run into an issue with macOS where there is obviously screen scaling going on but the devicePixelRatio is always set to 1. This is how scaling variables look like on his machine:

devicePixelRatio: 1
devicePixelRatioF: 1
logicalDpiX: 72
logicalDpiY: 72 
physicalDpiX: 114
physicalDpiy: 114

I have also tried reading out the values from QApplication::primaryScreen()but they look the same.

QScreen devicePixelRatio: 1
QScreen logicalDotsPerInch: 72
QScreen logicalDotsPerInchX: 72
QScreen logicalDotsPerInchY: 72
QScreen physicalDotsPerInch: 113.5
QScreen physicalDotsPerInchX: 113.5
QScreen physicalDotsPerInchY: 113.5

According to my user he should have 227 dpi: "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."

Any idea whats going on here or how we could detect the scale factor?

Damir Porobic
  • 681
  • 1
  • 8
  • 21
  • Weird, I've never seen anything but `2` here. Are you really sure he has a retina display, and isn't using an external monitor etc.? I'd start with asking for the exact model (About this Mac -> Overview) and macOS version. Which Qt version are you using? – Frank Osterfeld Jul 23 '20 at 06:41
  • I have tested with with `5.13.2` and `5.15.0`. I'll ask about the exact version – Damir Porobic Jul 23 '20 at 08:55
  • The Mac Version seems to be `Mac Catalina 10.15.5` – Damir Porobic Jul 27 '20 at 13:25

0 Answers0