from PyQt5.QtGui import QColor from PyQt5.QtWidgets import QApplication, QWidget, QLabel app = QApplication([]) widget = QWidget() label = QLabel("Hello World!", widget) blue = QColor(0, 0, 255) label.setStyleSheet("color: %s;" % blue.name()) widget.show() app.exec_()
from PyQt5.QtGui import QColor, QPalette from PyQt5.QtWidgets import QApplication, QWidget app = QApplication([]) widget = QWidget() palette = QPalette() palette.setColor(QPalette.Window, QColor(255, 255, 255)) palette.setColor(QPalette.WindowText, QColor(0, 0, 0)) palette.setColor(QPalette.Base, QColor(255, 255, 255)) palette.setColor(QPalette.Text, QColor(0, 0, 0)) widget.setPalette(palette) widget.show() app.exec_()In this example, we created a QWidget and a QPalette object. We then used the setColor method of the QPalette object to set the colors for various elements of the GUI, such as the window background and text color. Finally, we set the widget's palette to use the QPalette we created. In summary, QSqlColor is a class in the PyQt5.QtGui library package that is used to represent colors in graphical user interfaces developed in Python using the PyQt5 package.