summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-28 01:00:09 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2020-01-28 16:02:04 +0100
commit6c3eb39832876a65291546476b92fd94950b1208 (patch)
tree2d551aab7fce80b2ef603f1cfc42bf6f9d0e4411 /src/sql
parentfcd3a20059d0c629d972ba2577694394b438a100 (diff)
parent082faeff9c4c5a5b10d140b391d30305575a898b (diff)
Merge "Merge remote-tracking branch 'origin/5.14' into 5.15"
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/doc/snippets/sqldatabase/sqldatabase.cpp10
-rw-r--r--src/sql/models/qsqlquerymodel.cpp4
-rw-r--r--src/sql/models/qsqltablemodel.cpp2
3 files changed, 8 insertions, 8 deletions
diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
index bba0487452..a45b5f409a 100644
--- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
+++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp
@@ -249,16 +249,15 @@ void QSqlQueryModel_snippets()
}
//! [21]
- QSqlTableModel model;
- model.setTable("employee");
- model.select();
+ QSqlQueryModel model;
+ model.setQuery("SELECT name, salary FROM employee");
int salary = model.record(4).value("salary").toInt();
//! [21]
Q_UNUSED(salary);
{
//! [22]
- int salary = model.data(model.index(4, 2)).toInt();
+ int salary = model.data(model.index(4, 1)).toInt();
//! [22]
Q_UNUSED(salary);
}
@@ -308,7 +307,8 @@ void QSqlTableModel_snippets()
//! [25]
QSqlTableModel model;
model.setTable("employee");
- QString name = model.record(4).value("name").toString();
+ model.select();
+ int salary = model.record(4).value("salary").toInt();
//! [25]
}
}
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp
index c0b1061c6b..31d0ec985d 100644
--- a/src/sql/models/qsqlquerymodel.cpp
+++ b/src/sql/models/qsqlquerymodel.cpp
@@ -124,8 +124,8 @@ int QSqlQueryModelPrivate::columnInQuery(int modelColumn) const
\snippet sqldatabase/sqldatabase.cpp 21
The code snippet above extracts the \c salary field from record 4 in
- the result set of the query \c{SELECT * from employee}. Assuming
- that \c salary is column 2, we can rewrite the last line as follows:
+ the result set of the \c SELECT query. Since \c salary is the 2nd
+ column (or column index 1), we can rewrite the last line as follows:
\snippet sqldatabase/sqldatabase.cpp 22
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 4b29492134..7d2421d34e 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -222,7 +222,7 @@ bool QSqlTableModelPrivate::exec(const QString &stmt, bool prepStatement,
QSqlTableModel can also be used to access a database
programmatically, without binding it to a view:
- \snippet sqldatabase/sqldatabase.cpp 21
+ \snippet sqldatabase/sqldatabase.cpp 25
The code snippet above extracts the \c salary field from record 4 in
the result set of the query \c{SELECT * from employee}.