PyQt5 – Count the number of items in ComboBox
In this article we will see how we can find the total number of items present in the combo box. We know we can add items in the combo box with the help of addItem method to add single item and addItems method to add multiple items. In order to get the count of all the items in the combo box we will use count method.
Syntax : combo_box.count()
Argument : It takes no argument
Return : It will return integer i.e number of items in combo box
Steps for implementation: 1. Create a combo box 2. Add items to combo box 3. Create push button 4. Add action to the push button 5. Create label to show count 5. Inside the action count the items of combo box with the help of count method and store it in variable 6. Show the count variable in label with the help of setText method Below is the implementation –