When it comes to choosing between
color, it solely depends on the matter of your taste.
There are three key differences:
coloris a wrapper around
qolor, so you can't assign it directly to QML's
colorproperty. You need to unwrap it first.
qolormisses some properties that
colorhas. For example, it lacks HWB support completely.
- You can chain color transformations on
colorvia dot-syntax, but not on
qolorwhere you have to use procedural style with functions.
I'll demonstrate these and other differences on the examples below:
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).