QColor myColor(Qt::red); qreal sat = 0.5; myColor.setHsvF(myColor.hueF(), sat, myColor.valueF());
QColor myColor(Qt::blue); qreal sat = myColor.saturationF(); qDebug() << "Saturation: " << sat;In this example, we create a QColor object and set it to the color blue. Then we use the saturationF() method to retrieve the saturation component of the color and store it in a variable. Finally, we print the saturation value using qDebug() function. Package library: Qt Core.