QColor myColor(255, 0, 0); //create a color with 255 red, 0 green, and 0 blue myColor.setBlueF(0.5); //set the blue value to 0.5 or 50%
QColor myColor(0, 0, 0); //create a color with 0 red, 0 green, and 0 blue myColor.setBlueF(0.75); //set the blue value to 0.75 or 75%In this example, we create a black color with no red, green, or blue values. Then, we use the setBlueF function to change the blue value to 0.75 or 75%. Package library: Qt C++ library.