'Updating PyQt5 GUI with Live Data Tablewwidget
I created a PyQt5 using QtDesigner and converted it to Python.I got stacked on click function, its supposed to add row info,but the issue is the app didnot refresh data, I need to click each cell to update data. What should I need to change to refresh the data well
def retranslateUi(self, MainWindow):
self.pushButton.setText(_translate("MainWindow", "批量划扣"))
self.pushButton.clicked.connect(self.thread)
def thread(self):
t1=Thread(target=self.operation)
t1.start()
def operation(self):
row=0
self.tableWidget.setRowCount(len(user_data))
for i in range(len(user_data)):
self.tableWidget.setItem(row,0,QtWidgets.QTableWidgetItem(customerName[i]))
self.tableWidget.setItem(row,1,QtWidgets.QTableWidgetItem(koukuan(appidnum[i],bankopen[i],bankcard[i],amt[i],overDueMoney[i],overduePi[i],fileMark[i],attachment[i],overduePrincipal[i],overdueInterest[i])))
time.sleep(1.5)
self.tableWidget.setItem(row,2,QtWidgets.QTableWidgetItem(chenggong(casenum[i])))
row=row+1
app.processEvents()
time.sleep(1)
Solution 1:[1]
You should not use external threads to handle pyqt UI..
Instead use QThread and signal/slot to send data to UI and update it upon new received data
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ayush Shah |
