Search code examples
pythonpyqt5qtwidgets

Find a Value in a cell QT Table Widget by having row number and column number in Python


I have a QT Table Widget in python where I find the row number and the column number of the last item changed by the user in this way :

class elencoviaggi(QtWidgets.QDialog):
 def __init__(self):
    super(elencoviaggi, self).__init__()
    uic.loadUi('elenco_viaggi.ui', self)
    self.tabella_registrazioni.setColumnWidth(0, 30)
    self.tabella_registrazioni.setColumnWidth(1, 100)
    self.botton = self.findChild(QtWidgets.QPushButton, 'pushButton_3') 
    self.botton.clicked.connect(self.salva) !

 def salva(self): 
    print(self.tabella_registrazioni.itemChanged.connect(self.changeIcon))   
 def changeIcon(self, item):
    row = item.row()
    col = item.column()

In this part of the code I correctly find through a button the row number and the column number of the last item changed by the user, how can I store in a variable the item that has column 0 and as row the "row" variable declared? I tried this tabella_registrazioni.Item(row, 0) but doesn't work. I don't know what is the command to find an item using row and column numbers


Solution

  • If someone has the same issue the command is :

    self.yourtablename.item(therownumber, thecolumnnumber)