In this article we will see how we can get the current index of the selected item the combo box. In order to do this we will use the
Syntax : combo_box.currentIndex()
Argument : It takes no argument
Return : It return integer i.e index of selected item
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 get the index of current item selected in combo box with the help of
currentIndex method and store it in variable
6. Show the index in label with the help of
Below is the implementation –
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.
- PyQt5 - Getting the role of selected item in ComboBox
- PyQt5 - Getting the text of selected item in ComboBox
- PyQt5 - How to hide ComboBox when new item get selected
- PyQt5 - Getting the content of item at specific index in ComboBox
- PyQt5 QListWidget - Getting Current Selected Row
- PyQt5 - Change the item at specific index in ComboBox
- PyQt5 - Adding item at given index in ComboBox
- PyQt5 QListWidget - Getting Current Item
- PyQt5 - Setting current index in ComboBox
- PyQt5 ComboBox – User entered items store at selected position
- PyQt5 ComboBox – User entered items store after the selected position
- PyQt5 ComboBox – User entered items store before the selected position
- PyQt5 QListWidget - Setting Current Selected Row
- PyQt5 QListWidget - Current Selected Row Signal
- PyQt5 QDateTimeEdit – Getting Current Section Index
- PyQt5 - Setting role to item in ComboBox
- PyQt5 - How to add an item to the ComboBox ?
- PyQt5 - Accessing role of item in ComboBox
- PyQt5 - Finding the item through text in ComboBox
- PyQt5 - Finding item through their role in comboBox
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.