Reputation: 2811
I have an object of QTableWidget. Whenever, I click on a cell of the table, it becomes blue. How can I make a cell blue, say the cell located at row 1 and column 1, programmatically.
Upvotes: 1
Views: 2232
Reputation: 244282
You have to use the selectionModel
:
row = 1
column = 1
index = table_widget.model().index(row, column)
table_widget.selectionModel().select(
index, QItemSelectionModel.Select | ItemSelectionModel.Current
)
Upvotes: 3