From 8ba9d2e0220777bc1a2322eeece7fa9a5c55a96d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 11 Jun 2020 10:49:50 +0200 Subject: Change boundValues() to return a QVariantList This enables the order of boundValues to be consistent as with a QMap it could have been reordered which can be a problem for positional bindings. [ChangeLog][QtSQL] Changed signature of QSqlQuery::boundValues() to return a QVariantList Fixes: QTBUG-51609 Change-Id: I1c80fa8522fa7352723420b6fc9ec466406315fb Reviewed-by: Volker Hilsheimer --- src/sql/doc/snippets/sqldatabase/sqldatabase.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src/sql/doc/snippets/sqldatabase') diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp index c28e750b16b..001e2ba3b2b 100644 --- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp +++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp @@ -50,7 +50,6 @@ #include #include -#include #include using namespace std; @@ -202,23 +201,12 @@ void QSqlQuery_snippets() QSqlQuery query; { - // examine with named binding + // examine with named or positional binding //! [14] - QMap sqlIterator(query.boundValues()); - for (auto i = sqlIterator.begin(); i != sqlIterator.end(); ++i) { - cout << i.key().toUtf8().data() << ": " - << i.value().toString().toUtf8().data() << "\n"; - } -//! [14] - } - - { - // examine with positional binding -//! [15] - QList list = query.boundValues().values(); + QVariantList list = query.boundValues(); for (int i = 0; i < list.size(); ++i) cout << i << ": " << list.at(i).toString().toUtf8().data() << "\n"; -//! [15] +//! [14] } } -- cgit v1.2.3