from PyQt5.QtGui import QColor # Create a red color object red = QColor(255, 0, 0) # Print the RGB values of the color object print(red.red(), red.green(), red.blue()) # Output: 255 0 0
from PyQt5.QtGui import QColor # Create a blue color object blue = QColor("#0000FF") # Print the RGB values of the color object print(blue.red(), blue.green(), blue.blue()) # Output: 0 0 255In conclusion, these code examples use the QColor class from the PyQt5.QtGui package library to create color objects with RGB and hexadecimal values. These color objects can be used in various GUI components to provide a visual representation of the data or functionality.