开发者

PyQT QtGui.QTableWidgetItem

I have a QtGui.QTableWidgetItem that I added to a table by the createRow function below:

def createRow(self, listA):
    rowNum = self.table.rowCount()
    self.table.insertRow(rowNum)
    i = 0
    for val in listA:
        self.table.setItem(rowNum, i, QtGui.QTableWidgetItem(val))
        i += 1

Now I have a thread that will update the row values periodically. The function called by the thread is the following:

d开发者_如何学JAVAef updateRow(self, listB):
    row = 0
    numRows = self.table.rowCount()
    i = 0
    while i < numRows:

        if listB[0] == self.table.item(i,0):
            row = i
        i+=1
    j = 0
    for val in listB:
        self.table.setItem(row, j, QtGui.QTableWidgetItem(val))
        j += 1

However, this is not working, because listB[0] is a string and self.table.item(i,0) is a QTableWidgetItem. Anyone know how I could solve this?

In the end, all I want is to update the row for the items that match the first item in the list this function takes as an input (listB).


Use QTableWidgetItem.text(self) (i.e.: self.table.item(i,0).text()) to get the contents of a cell/QTableWidgetItem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜