summaryrefslogtreecommitdiffstats
path: root/src/sql/doc/snippets/code/src_sql_models_qsqlquerymodel.cpp
blob: 6577c02f402271d3c6666d765d9dc607ac1daff6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlDriver>
#include <QVariant>
#include "../sqldatabase/sqldatabase.cpp"

void MyModel::fetchModel()
{
MyModel *myModel = new MyModel;
//! [0]
while (myModel->canFetchMore())
    myModel->fetchMore();
//! [0]

//! [1]
QSqlQueryModel model;
model.setQuery("select * from MyTable");
if (model.lastError().isValid())
    qDebug() << model.lastError();
//! [1]
}