from PyQt5.QtWidgets import QComboBox, QApplication app = QApplication([]) combo_box = QComboBox() items = ["Apple", "Banana", "Orange"] combo_box.addItems(items) combo_box.show() app.exec_()
from PyQt5.QtWidgets import QComboBox, QApplication app = QApplication([]) combo_box = QComboBox() for i in range(1, 6): combo_box.addItem(f"Item {i}") combo_box.show() app.exec_()In this example, we create a new QComboBox widget and use a for loop to add five items to the widget using the addItem() method. The PyQt5 package library was used in this example.