QComboBox is a widget in PyQt5 which is used to choose from a list. It takes minimum space when we click on combo box, a drop down list came from which we can select the item. QComboBox class is used to add a combo box in a application. Below is the representation of how combo looks like –

Example :
In this we will create a combo box in the window which allows us to choose in between “Geek”, “Super Geek” and “Ultra Geek”
Below is the code –
# importing libraries 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__() # setting title self.setWindowTitle("Python ") # setting geometry self.setGeometry(100, 100, 600, 400) # calling method self.UiComponents() # showing all the widgets self.show() # method for widgets def UiComponents(self): # creating a combo box widget combo_box = QComboBox(self) # setting geometry of combo box combo_box.setGeometry(200, 150, 120, 40) # adding items to combo box combo_box.addItem("Geek") combo_box.addItem("Super Geek") combo_box.addItem("Ultra Geek") # create pyqt5 app App = QApplication(sys.argv) # create the instance of our Window window = Window() # start the app sys.exit(App.exec()) |
Output :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- PyQt5 QComboBox – Checking if mouse tracking is activated or not
- PyQt5 QComboBox - Setting mouse tracking
- PyQt5 QComboBox - Change border style on mouse hover
- PyQt5 QComboBox - Change border style when pressed
- PyQt5 QComboBox - Change border style when it is editable
- PyQt5 QComboBox - Change border style when it is non-editable
- PyQt5 QComboBox - Change border style when it is non-editable and mouse hover
- PyQt5 QComboBox - Change border style when it is editable and mouse hover over it
- PyQt5 QComboBox - Change border style when editable and get pressed
- PyQt5 QComboBox - Change border style when it is non-editable and get pressed
- PyQt5 QComboBox - Setting different corners
- PyQt5 QComboBox - Change border style
- PyQt5 QComboBox – Change border style when it editable and off state
- PyQt5 QComboBox – Change border style when it editable and on state
- PyQt5 QComboBox – Change border style when it non-editable and off state
- PyQt5 QComboBox – Change border style when it non-editable and on state
- PyQt5 QComboBox - Change border style when it is in off state
- PyQt5 QComboBox - Change border style when it is in off state and mouse hover over it
- PyQt5 QComboBox - Change border style when it is in off state and when it get pressed
- PyQt5 QComboBox – Change border style of lineedit part for non editable state and mouse hover
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

