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
qsqlquerymodel.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSQLQUERYMODEL_H
5#define QSQLQUERYMODEL_H
6
7#include <QtSql/qtsqlglobal.h>
8#include <QtCore/qabstractitemmodel.h>
9#include <QtSql/qsqldatabase.h>
10
12
14
16class QSqlError;
17class QSqlRecord;
18class QSqlQuery;
19
20class Q_SQL_EXPORT QSqlQueryModel: public QAbstractTableModel
21{
23 Q_DECLARE_PRIVATE(QSqlQueryModel)
24
25public:
26 explicit QSqlQueryModel(QObject *parent = nullptr);
27 virtual ~QSqlQueryModel();
28
29 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
30 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
31 QSqlRecord record(int row) const;
32 QSqlRecord record() const;
33
34 QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const override;
35 QVariant headerData(int section, Qt::Orientation orientation,
36 int role = Qt::DisplayRole) const override;
37 bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
38 int role = Qt::EditRole) override;
39
40 bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
41 bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
42
43#if QT_DEPRECATED_SINCE(6, 2)
44 QT_DEPRECATED_VERSION_X_6_2("QSqlQuery is not meant to be copied. Pass it by move instead.")
45 void setQuery(const QSqlQuery &query);
46#endif
47 void setQuery(QSqlQuery &&query);
48 void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase());
49#if QT_SQL_REMOVED_SINCE(6, 5)
50 QSqlQuery query() const;
51#endif
53
54 virtual void clear();
55
56 QSqlError lastError() const;
57
58 void fetchMore(const QModelIndex &parent = QModelIndex()) override;
59 bool canFetchMore(const QModelIndex &parent = QModelIndex()) const override;
60
61 QHash<int, QByteArray> roleNames() const override;
62
63protected:
64 void beginInsertRows(const QModelIndex &parent, int first, int last);
65 void endInsertRows();
66
67 void beginRemoveRows(const QModelIndex &parent, int first, int last);
68 void endRemoveRows();
69
70 void beginInsertColumns(const QModelIndex &parent, int first, int last);
71 void endInsertColumns();
72
73 void beginRemoveColumns(const QModelIndex &parent, int first, int last);
74 void endRemoveColumns();
75
76 void beginResetModel();
77 void endResetModel();
78 virtual void queryChange();
79
80 virtual QModelIndex indexInQuery(const QModelIndex &item) const;
81 void setLastError(const QSqlError &error);
82 QSqlQueryModel(QSqlQueryModelPrivate &dd, QObject *parent = nullptr);
83};
84
86
87#endif // QSQLQUERYMODEL_H
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
The QSqlDatabase class handles a connection to a database.
The QSqlError class provides SQL database error information.
Definition qsqlerror.h:17
The QSqlQueryModel class provides a read-only data model for SQL result sets.
The QSqlQuery class provides a means of executing and manipulating SQL statements.
Definition qsqlquery.h:24
The QSqlRecord class encapsulates a database record.
Definition qsqlrecord.h:20
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
b clear()
Combined button and popup list for selecting options.
Orientation
Definition qnamespace.h:98
@ EditRole
@ DisplayRole
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint first
GLenum GLenum GLsizei void GLsizei void * column
GLenum query
GLenum GLenum GLsizei void * row
#define QT_REQUIRE_CONFIG(feature)
#define QT_DEPRECATED_VERSION_X_6_2(text)
#define Q_OBJECT
#define QT6_DECL_NEW_OVERLOAD
model setHeaderData(0, Qt::Horizontal, tr("Name"))
qDebug()<< QUrl("file copy setQuery(copy.query(QUrl::FullyDecoded), QUrl::DecodedMode)
beginInsertRows(parent, 2, 4)
[0]
beginInsertColumns(parent, 4, 6)
[2]
beginRemoveColumns(parent, 4, 6)
[4]
beginRemoveRows(parent, 2, 3)
[1]
QMimeDatabase db
[0]
MyRecord record(int row) const
[0]
QGraphicsItem * item