Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
src_sql_kernel_qsqlerror.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 <QSqlQueryModel>
6#include <QSqlError>
7#include <QDebug>
8
10{
13model.setQuery("select * from myTable");
14if (model.lastError().isValid())
15 qDebug() << model.lastError();
17}
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.
QSqlError lastError() const
Returns information about the last error that occurred on the database.
#define qDebug
[1]
Definition qlogging.h:160
QSqlQueryModel * model
[16]
void checkSqlQueryModel()