Model->setHeaderData(0, Qt::Horizontal, QObject::tr("Country")) Model->setHeaderData(0, Qt::Horizontal, QObject::tr("City")) Model->setHeaderData(0, Qt::Horizontal, QObject::tr("Name")) The view class displays a header at the top of the view, and you can call the setHeaderData() function of the model to modify the header text.The following code sets the title bar as the field name of the data table: model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID")) Multiple views can use the same data Model, and when data is modified in one View, the other View immediately refreshes the display. Settings View Not Editable view->setEditTriggers(QAbstractItemView::NoEditTriggers) View creation: Create a new view and set a data source for it: QTableView *view = new QTableView The three classes QSqlQueryModel, QSqlTableModel and QSqlRelationalTableModel can be used as data sources for Qt View related display classes, such as QTableView, QListView and QTreeView.The most common should be the QTableView, because the resulting dataset of an SQL statement must be a two-dimensional data structure. Qt Assistant Keyword: Presenting Data in a Table View
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
May 2023
Categories |