Working with python, I have a QTableWidget.
I need to perform computations with contents of the table In my table constructor:
for i in range(rowNumber):
for j in range(columnNumber):
cellLineEdit = QLineEdit()
cellLineEdit.textChanged.connect(self.sync_lineEdit)
self.tableWidget.setCellWidget(i, j, cellLineEdit)
The sync_lineEdit function:
def sync_lineEdit(self, text):
#perform computations using the table contents.
Is there a way to add the row of the table to the sync_lineEdit call? Ideally, I would love it to be a parameter of the sync_lineEdit function.
As @musicamante proposed, the following solution worked
In constructor:
rowNumber = self.tableWidget.rowCount()
columnNumber = self.tableWidget.columnCount()
for i in range(rowNumber):
for j in range(columnNumber):
self.tableWidget.openPersistentEditor(self.tableWidget.itemAt(rowNumber, columnNumber))
self.tableWidgetHomme.cellChanged.connect(self.sync_lineEdit)
The callback:
def sync_lineEditHomme(self, row, column):
print("row = ", row, "column = ", column)
#access an other element of the table for calculations :
Value = int(self.tableWidget.item(row,0).text())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.