Question

I want to add data (read from a file) to the QTableView, but looking over the functions at http://srinikom.github.io/pyside-docs/PySide/QtGui/QTableView.html#qtableview, there doesn't seem to be anything that does that.

I've been lead to believe that I should be using TableView instead of tabelWidget for custom data.

Was it helpful?

Solution

The reason for using a QTableView is that rather than adding data to the view directly, you can use the Model-View-Controller paradigm instead.

You need to create a subclass of QAbstractItemModel, and then set the model using QAbstractItemView.setModel(), which QTableView inherits from.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top