In the preceding sections we discussed various model classes. Now, we will look at how to present the data to the users using the
QTableView widget. The data source for the
QTableView widget is provided by any of the model classes. The table view is the most used view format as this represents a virtual representation of the
2D SQL table structure. We will have a look at the code first, and then discuss its functionality.
import sys from PySide.QtGui import * from PySide.QtCore import Qt from PySide.QtSql import * def initializeModel(model): model.setTable("employee") model.setEditStrategy(QSqlTableModel.OnManualSubmit) model.select() model.setHeaderData(0, Qt.Horizontal, "ID") model.setHeaderData(1, Qt.Horizontal, "First Name") model.setHeaderData(2, ...