[Development] Scalable UIs in QtQuick (take 2)

Nikita Krupenko krnekit at gmail.com
Fri Feb 19 09:48:43 CET 2016


2016-02-19 0:08 GMT+02:00 Dominik Haumann <dhaumann at kde.org>:
> Interestingly, I once wrote a Value class [1] that does exactly this.
> It allows to have
> constructs like this:
>
> Value v1(2, Unit::Centimeter);
> Value v2 = Value::fromString("1in)"; // see also: toString()
> Value v3 = v1 * v2; // Restult is 4.45 cm
> bool v2GreaterThanv1 = v2 > v1; // = true
>
> Value v4(0, Unit::Millimeter);
> Value v5 = v1 / v4; // v5.isValid() == false

> So from my experience, writing this Value class was a very good decision.
> Although I personally don't program much in QML, I still believe that something
> like this (or similar) is probably worth it (in QML and probably overall in Qt).

In C++11 (which is required for Qt 5.7+) user-defined literals can
simplify usage of units. Good video from QtDD on this:
https://www.youtube.com/watch?v=39Yrk3FVFIc



More information about the Development mailing list