DPI-independent constant size in QML

765 views Asked by At

I have a visual component in my app written in QML, Qt5. I want it to always have the width of 5 cm on the screen, no matter what device is used.

If I set width: somevalue, then the DPI might differ among the devices which will result in different physical size on different devices.

Is there any way to achieve my goal?

1

There are 1 answers

0
marmistrz On BEST ANSWER

Well, I've just might've found a solution: Screen.pixelDensity. But feel free to suggest anything better.