Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_sql_models_qsqlquerymodel.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QSqlDatabase>
4#include <QSqlQuery>
5#include <QSqlDriver>
6#include <QVariant>
8
10{
11MyModel *myModel = new MyModel;
13while (myModel->canFetchMore())
14 myModel->fetchMore();
16
19model.setQuery("select * from MyTable");
20if (model.lastError().isValid())
21 qDebug() << model.lastError();
23}
bool isValid() const
Returns true if an error is set, otherwise false.
The QSqlQueryModel class provides a read-only data model for SQL result sets.
void setQuery(QSqlQuery &&query)
Resets the model and sets the data provider to be the given query.
void fetchMore(const QModelIndex &parent=QModelIndex()) override
Fetches more rows from a database.
QSqlError lastError() const
Returns information about the last error that occurred on the database.
#define qDebug
[1]
Definition qlogging.h:164
QSqlQueryModel * model
[16]