QColorDialog It is a dialog box of a color picker widget. A color picker is a graphical user interface widget, usually found within graphics software or online, used to select colors and sometimes to create color schemes. Below is how the QColorDialog looks like

It is popup type widget in PyQt5 it basic use is to allow user to choose the color this widget is very useful in designing application like paint.
Example :
In this we will create a PyQt5 application which when executed will open the color dialog and when user choose the color and close the dialog there will be our main window which has a label and its color will be same as of the color selected in the dialog.4
Below is the implementation
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Python " )
self .setGeometry( 100 , 100 , 500 , 400 )
self .UiComponents()
self .show()
def UiComponents( self ):
color = QColorDialog.getColor()
label = QLabel( self )
label.setGeometry( 100 , 100 , 200 , 60 )
label.setWordWrap( True )
label.setStyleSheet( "QLabel"
"{"
"border : 5px solid black;"
"}" )
label.setText( str (color))
graphic = QGraphicsColorizeEffect( self )
graphic.setColor(color)
label.setGraphicsEffect(graphic)
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
21 Jun, 2020
Like Article
Save Article