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();