[英]How to deselect an entire QTableWidget row
Given the row index, how can I deselect a single row in a QTableWidget?给定行索引,如何取消选择 QTableWidget 中的单行? I don't want to deselect everything using clearSelection()我不想使用 clearSelection() 取消选择所有内容
You can use the table selectionModel()
and its select()
function, using the Deselect
and Rows
flags:您可以使用表selectionModel()
及其select()
函数,使用Deselect
和Rows
标志:
def deselectRow(self, row):
if row > self.table.rowCount() - 1:
return
selectionModel = self.table.selectionModel()
selectionModel.select(self.table.model().index(row, 0),
selectionModel.Deselect|selectionModel.Rows)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.