How to use the displayScaleFactor?

330
2
Jump to solution
07-05-2017 11:40 AM
esri
by
Occasional Contributor III

So, I guess I don't understand exactly how to take advantage of the displayScaleFactor value.

A scale factor for the current system display, based on the ratio of the logical DPI to the physical DPI.

I actually don't use it in my current app since I'm developing for a specific iPad model, but I know it could be useful in the future.

One part I don't understand is how do you know what to put for the initial value?

For example, if I had:

font.pixelSize: 14 * scaleFactor‍‍

How do I know to start with a size of 14? Does the scale factor make it so the font is truly pixel size 14 no matter which device?

I assume this is a dumb question, but there's something I don't complete understand. Is there any further documentation on this, or a simple explanation that might help me understand?

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

Basically, the issue is that most UI elements in QML are defined in raw pixels. However, due to extremely different screen resolutions from a high end Android device to a low end Windows monitor, 14 pixels will look much different. On a very high DPI device, 14 pixels would be very tiny, and on a lower DPI device, it might look how you want. So, we provided this helper that basically figures out a factor that you need to multiply the raw pixel value by so that it looks exactly the same on all devices, no matter the resolution. 

One of the newer features of Qt is to enable high DPI support. This is something you can try if you like. We have found that it doesn't always work well on some platforms, but in general it seems to work well. More info can be found about this on Qt's website - High DPI Displays | Qt 5.9 

View solution in original post

2 Replies
LucasDanzinger
Esri Frequent Contributor

Basically, the issue is that most UI elements in QML are defined in raw pixels. However, due to extremely different screen resolutions from a high end Android device to a low end Windows monitor, 14 pixels will look much different. On a very high DPI device, 14 pixels would be very tiny, and on a lower DPI device, it might look how you want. So, we provided this helper that basically figures out a factor that you need to multiply the raw pixel value by so that it looks exactly the same on all devices, no matter the resolution. 

One of the newer features of Qt is to enable high DPI support. This is something you can try if you like. We have found that it doesn't always work well on some platforms, but in general it seems to work well. More info can be found about this on Qt's website - High DPI Displays | Qt 5.9 

View solution in original post

esri
by
Occasional Contributor III

That was helpful, thanks

0 Kudos