Changes to Qt SQL

Qt 6 是努力使框架更高效,且更易于使用的结果。

为兼容每个发行的所有公共 API,我们试着维护二进制和源代码。但是,为使 Qt 成为更优框架,一些改变是不可避免的。

In this topic we summarize those changes in Qt SQL, and provide guidance to handle them.

The QSqlQuery class

boundValues() Signature

The return type for boundValues() has been changed from QMap < QString , QVariant > to a QVariantList. The order can be relied upon so it will be in the order of the binding in the prepared query. Change code like the following:

QMap<QString, QVariant> values = boundValues();
int id = values[":id"].value().toInt();
					
QList<QVariant> values = boundValues().values();
int id = values.at(0).toInt();
					

to:

QList<QVariant> values = boundValues().values();
int id = values.at(0).toInt();