How get currentIndex() property from combobox inside table in Python

12.6k views Asked by At

I am no so strong in object programing in Python, so I have to ask for a help.

I create a combobox inside table this way (it works):

self.comboBoxEng = QtGui.QComboBox()
self.tableWidget_1.setCellWidget(row,column,self.comboBoxEng)

The question is:
How to get currentIndex() property (for example...) from combobox which is used as tableWidgetItem?

2

There are 2 answers

0
M Orio On

In one line

index = *self.tableWidget_1.cellWidget(row, column).currentIndex()

or any other info like currenText().

2
Aleksandar On

With this line you get cell widget out of table (in your case combo box)

comboBox = self.tableWidget_1.cellWidget(row, column)

and then simply take current index of that combo box:

index = comboBox.currentIndex()