#includeint main() { QColor color(255, 150, 0); // orange color int lightness = color.lightness(); // returns 137 return 0; }
#includeThe package library for QColor is Qt.int main() { QColor color(255, 150, 0); // orange color int lightness = color.lightness(); // returns 137 if (lightness < 127) { color = color.lighter(150); // make the color brighter } else { color = color.darker(150); // make the color darker } return 0; }