QColor color(255, 0, 0); // create a red color object color.setAlphaF(0.5); // set the alpha channel value to 0.5 or 50%
QColor color(0, 255, 0, 128); // create a semi-transparent green color object float alpha = color.alphaF(); // gets the alpha channel value as a float between 0.0 and 1.0Package Library: The QColor class is part of the Qt Core module and can be accessed by including the header file "QColor" and linking against the Qt Core library.