Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QScreen DPI Confusion



  • Hello!

    My app draws things in real-world millimetre dimensions. For that, I take:

    qreal oneMM = QScreen::logicalDotsPerInchX() * QScreen::devicePixelRatio() / 25.4f;
    

    On a MacBook Pro with a built-in Retina display this works perfectly. 10mm on the screen are actually 10mm in real life if you put a ruler up to the screen.

    However, on my Mac Pro with an external 4K Benq SW271 display in scaled 1:2 mode at 1920x1080 down from 3840 x 2160, the same formula looks like 18mm in real life even though it draws 10mm in the code.

    If I draw the same 10mm to a Printer device using the same exact code but with the printer's DPI settings, the code prints a perfect 10mm as expected.

    Now I don't think there's a bug with anything in particular, but there much be a way of accounting for that difference between the built-in and the external display that I'm completely missing.

    Can anyone advise please?



  • At least in X11, displays have a concept called an EDID that informs the server about the modes, frequencies, and dimensions of the physical display. Unfortunately how that infomration is used between differing OS, desktop environments, and even APPS is not well defined. It gets a lot more complicated when you mirror displays that have different DPI values. Wish I did have a solution, but for me it's always trial-and-error with bunches of different settings and hoping they don't screwup things outside of the app I'm concerned about.



  • Thank you very much Kent,

    I fear you are right. I've actually been debugging this issue with Qt support and it seems that the BenQ SW271 is either reporting incorrect information to the operating system or it is being recognised incorrectly by the operating system. In the "About My Mac" window, macOS thinks the screen is 61-inch (3840 x 2160)! And hence the incorrect DPI :-/ I've now written to BenQ's support. The ticket was escalated to the technical team and I'm waiting for reply.

    Luckily, the printing works perfectly so it's not stopping the app from working correctly at the end of the day.


Log in to reply