Calling value from model through pair of integers representing row and column

Hi, if I want to call the value (as a string say) from the model (through a buttonclick from a pushbutton in the mainwidget), not through clicking in a cell in the QTableView but giving the information through a pair of integers.
lets say row 0, column 0.
Given the structure in the tutorial “Displaying tabular data in Qt5 ModelViews”

I try
value = self.model.data(0, 0, QModelIndex(), Qt.DisplayRole).toString()

But it doesnt work.
(it crashes the app.)

Hi David!

You could try,

Index = self.model.index(0, 0)
value = self.model.data(index, Qt.DisplayRole)

1 Like

This worked.
Thank you.

1 Like