[Development] Scalable UIs in QtQuick (take 2)

Sorvig Morten Morten.Sorvig at theqtcompany.com
Thu Feb 18 13:05:38 CET 2016


> On 18 Feb 2016, at 12:35, Nikita Krupenko <krnekit at gmail.com> wrote:
> 
> 2016-02-18 12:50 GMT+02:00 Hausmann Simon <Simon.Hausmann at theqtcompany.com>:
>> (1) In order to make it really easy to scale "logical" pixels without having to introduce your own context property or factor in a .qml file that you multiply everywhere, we could turn the regular "pixels" in QtQuick into truly logical pixels that scale with an application wide (or window wide) factor. So Image { width: 100 ... } will scale automatically from 100 logical pixels to maybe 200 physical pixels on a x2 display. This assumes the availability of API to change this mapping.
>> 
>> (2) In the events where you still _want_ to use physical pixels, you could use "px" units.
>> 
>> So at first nothing would change for app developers at all because we map logical pixels to physical pixels. But
>> if you'd like to, you could opt into changing this mapping and having a relatively easy fallback to physical pixels using for example the "px" unit. We might as well offer the other physical units anyway, that probably causes little to no harm.
> 
> Isn't (1) already done with Qt::AA_EnableHighDpiScaling? Though
> disabling this feature for some items would be useful, like for
> Canvas, which is broken now with this scaling.

This is indeed what is done for that flag and on OS X and iOS. In that
sense logical pixels are already supported.

“px” could be added, but what are the use cases? You almost never want to
have small content on high-DPI display. I see doing custom scaling in the 
application as a possible one.

As a minor platform note, “px” would not be guaranteed to be physical pixels
on Apple operating systems. There can be further resolution virtualization,
for example when setting a scaled resolution for the display.

Morten





More information about the Development mailing list