Presenting Data in a Table View

<Unknown command>contentspageSQL Programming

The QSqlQueryModel, QSqlTableModel, and QSqlRelationalTableModel classes can be used as a data source for Qt's view classes such as QListView, QTableView, and QTreeView. In practice, QTableView is by far the most common choice, because an SQL result set is essentially a two-dimensional data structure.

A table view displaying a QSqlTableModel

The following example creates a view based on an SQL data model: