PYQT5在QTableWidget中找到一行并删除

  A  B  C
1 a1 b1 c1
2 a2 b2 c2
3 a3 b3 c3

Let's say I have this table. I want to find a row that matches with column value a2 and eventually delete that row. I tried this, but it's not getting it.

 for row in range(self.ui.table.rowCount()):
    for column in range(self.ui.table.columnCount()):
        item = self.ui.table.item(row, column)
        if item and item.data(Qt.DisplayRole) == "a2":
            return self.ui.table.indexFromItem(item)
     return None

如何找到表格并在表格中删除?

评论