2016-02-19 0:08 GMT+02:00 Dominik Haumann <[email protected]>: > 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 _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
