Reputation: 711
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?
Upvotes: 2
Views: 459