To represent database tables in the development
using QML You can use a class inherited from
. To do this, in the inherited class to define a method that would establish the respective roles of the table columns to the corresponding columns in the TableView, defined in the
, which also indicates the roles of each object
, that is, for each column. You will also need to override a method
QVariant data(...) const
, which returns the data for the table cells. In this case, the information will be returned in accordance with certain roles columns of the table.
The project structure to work with TableView
The project consists of the following files:
- the profile of the project;
- header to create and initialize the test database;
- file source code to create and initialize the test database;
- header data model file;
- file source data model;
- the main source file;
- qml file TableView.