qolor vs color¶
When it comes to choosing between qolor and color, it solely depends on the matter of your taste.
There are three key differences:
coloris a wrapper aroundqolor, so you can't assign it directly to QML'scolorproperty. You need to unwrap it first.qolormisses some properties thatcolorhas. For example, it lacks HWB support completely.- You can chain color transformations on
colorvia dot-syntax, but not onqolorwhere you have to use procedural style with functions.
I'll demonstrate these and other differences on the examples below:
Examples¶
Creating a color¶
using a color keyword in QML¶
using a color keyword in JS¶
using an ARGB literal¶
using an RGB32 literal¶
Accessing color components separately¶
Changing hue and saturation manually¶
Printing as HWB¶
Modification of a color¶
Inverting a color¶
Chain of modifications¶
Instead of conclusion¶
As you can see from examples, in most cases it's enough to use qolor and modifying functions. The real beauty of color comes when you need to chain modifications as methods or when you need to work with extended set of properties (for example, with HWB).