QColor color = QColor(125, 255, 0); //Create a color object with RGB values int hue = color.hue(); // retrieve the hue component of the color qDebug() << "The hue of the color is: " << hue;
QColor color = QColor::fromHsv(200, 255, 150); //Create a color object with HSV values int hue = color.hue(); // retrieve the hue component of the color qDebug() << "The hue of the color is: " << hue;This code creates a color object using HSV values and then retrieves the hue component of the color using the `hue()` method. The result is printed to the console using Qt's `qDebug()` method. Package library: Qt Core Library.