[Development] QColor and HSL's hue

Curtis Mitch mitch.curtis at theqtcompany.com
Sat Apr 9 15:02:36 CEST 2016


Is there any technical reason (besides compatibility) why QColor::hslHueF() can't return a value between 0 and 1?

I see that other projects do this:

https://developer.mozilla.org/en/docs/Web/CSS/color_value#hsl()
https://github.com/bgrins/TinyColor/issues/12

If the colour being represented by QColour is black, QColor::hslHueF() will return -1:

http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/painting/qcolor.cpp#n1787

This makes it difficult to construct colours from the HSL getters of QColor (when making a HSL-based colour picker, for example); how would I work around the case of a negative hue?


More information about the Development mailing list