Reputation: 2831
code:
QColor color = "#f0f0f0";
qDebug() << color;
qDebug() << color.toHsl();
qDebug() << color.convertTo(QColor::Hsl);
output:
QColor(ARGB 1, 0.941176, 0.941176, 0.941176)
QColor(AHSL 1, -1, 0, 0.941176) // hue == -1 here
QColor(AHSL 1, -1, 0, 0.941176) // hue == -1 here
from docs: QColor::fromHslF():
...
All the values must be in the range 0.0-1.0.
Docs for QML side color hsla():
Returns a color with the specified hue, saturation, lightness, and alpha components. All components should be in the range 0-1 (inclusive).
I need to get correct hue, saturation and lightness values on QML side. How to convert such RGB QColor to HSL QColor?
Upvotes: 0
Views: 353