Make QSqlQueryModel::query() return a reference to the const QSqlQuery
Returning QSqlQuery instance by value does not make much sense, because it cannot be copied correctly. Also, its copy constructor and copy-assignment operators are deprecated from Qt 6.2. [ChangeLog][Potentially Source-Incompatible Changes][QSqlQueryModel] QSqlQueryModel::query() now returns a reference to the const QSqlQuery object associated with the model. Task-number: QTBUG-105048 Change-Id: I04a2aa377b17d770d2a9855040f8c730190484d8 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
62859ccaa6
commit
2ca3044083
|
|
@ -17,6 +17,18 @@ QT_USE_NAMESPACE
|
|||
|
||||
#if QT_SQL_REMOVED_SINCE(6, 5)
|
||||
|
||||
#if QT_CONFIG(sqlmodel)
|
||||
|
||||
#include "qsqlquerymodel.h"
|
||||
#include "qsqlquery.h"
|
||||
|
||||
QSqlQuery QSqlQueryModel::query() const
|
||||
{
|
||||
QT_IGNORE_DEPRECATIONS(return query(QT6_CALL_NEW_OVERLOAD);)
|
||||
}
|
||||
|
||||
#endif // QT_CONFIG(sqlmodel)
|
||||
|
||||
// #include <qotherheader.h>
|
||||
// // implement removed functions from qotherheader.h
|
||||
// order sections alphabetically to reduce chances of merge conflicts
|
||||
|
|
|
|||
|
|
@ -522,18 +522,15 @@ bool QSqlQueryModel::setHeaderData(int section, Qt::Orientation orientation,
|
|||
}
|
||||
|
||||
/*!
|
||||
Returns the QSqlQuery associated with this model.
|
||||
Returns a reference to the const QSqlQuery object associated with this model.
|
||||
|
||||
\sa setQuery()
|
||||
*/
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
QSqlQuery QSqlQueryModel::query() const
|
||||
const QSqlQuery &QSqlQueryModel::query(QT6_IMPL_NEW_OVERLOAD) const
|
||||
{
|
||||
Q_D(const QSqlQueryModel);
|
||||
return d->query;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
||||
/*!
|
||||
Returns information about the last error that occurred on the
|
||||
|
|
|
|||
|
|
@ -46,7 +46,10 @@ public:
|
|||
#endif
|
||||
void setQuery(QSqlQuery &&query);
|
||||
void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase());
|
||||
#if QT_SQL_REMOVED_SINCE(6, 5)
|
||||
QSqlQuery query() const;
|
||||
#endif
|
||||
const QSqlQuery &query(QT6_DECL_NEW_OVERLOAD) const;
|
||||
|
||||
virtual void clear();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue