-1

In Python, using a QTableView how do I get a specific cell and how do I set the current cell.

QuentinJS
  • 162
  • 1
  • 9
  • for those who feel I deserve a -1, how should this be improved? As this was not an intuitive solution and I didn't see a question on here posted, so I wanted o help others. – QuentinJS Jan 25 '23 at 22:35

1 Answers1

-1

To get a specific cell from the QTableView aka "index" use:

e.g. for cell[0,0]

m = self.tbl.model()
itm = m.index(0, 0)

and to set a current position use the position you got above

sm = self.tbl.selectionModel()
sm.setCurrentIndex(itm, QItemSelectionModel.SelectionFlag.ClearAndSelect)
QuentinJS
  • 162
  • 1
  • 9