[Development] Units in QML (was: Re: Scalable UIs in QtQuick (take 2))

André Somers andre at familiesomers.nl
Thu Feb 25 08:48:25 CET 2016



Op 25/02/2016 om 01:41 schreef Michael Brasser:
> Hi,
>
> Regarding (2), last time around I had concerns about the proposed limitations associated with language-level unit support (see some of the discussion at https://codereview.qt-project.org/98288). I'd be interested to hear the particulars of what unit support might look like this time around.
>
> Regards,
> Michael
>
Thanks for bringing up that patch again, and pointing out your (valid!) 
concerns there as well again.

I think that generic unit support in the QML language would be awesome 
to have, but indeed I don't like it to be tied too much to Quick and 
screens. It would be great if it were possible somehow to define your 
own units in Quick or whatever other domain specific use you make of the 
language, and you then specify properties using those units in 
quantities instead of plain numerical values as we do now. Numerical 
values could be implicitly convertable to quantities, but not to each 
other unless such a relation is explicitly defined. That should prevent 
anyone from trying to do 3cm + 4s.

Perhaps the basic units and their relations could be defined by default 
already (the different length units like mm, cm, m*, inch, and the 
different time units ms, s, m*, h, day), and then adding domain specific 
units like px at the Quick level. In a domain application like aviation 
you may want to add specific units like FL (fleight level; which is an 
altitude in hundreds of feet above a standard isobaric reference plain 
at 1013,2 hectopascal), feet_QNH or m_QNH which can depend on some 
context variable.

Properties would be in some defined unit, and any numerical value 
assigned to that would be implicitly be regarded to be specified into 
that unit.

André


)* Note the first clash already...



More information about the Development mailing list