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>
This commit is contained in:
parent
62859ccaa6
commit
2ca3044083
@ -17,6 +17,18 @@ QT_USE_NAMESPACE
|
|||||||
|
|
||||||
#if QT_SQL_REMOVED_SINCE(6, 5)
|
#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>
|
// #include <qotherheader.h>
|
||||||
// // implement removed functions from qotherheader.h
|
// // implement removed functions from qotherheader.h
|
||||||
// order sections alphabetically to reduce chances of merge conflicts
|
// 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()
|
\sa setQuery()
|
||||||
*/
|
*/
|
||||||
QT_WARNING_PUSH
|
const QSqlQuery &QSqlQueryModel::query(QT6_IMPL_NEW_OVERLOAD) const
|
||||||
QT_WARNING_DISABLE_DEPRECATED
|
|
||||||
QSqlQuery QSqlQueryModel::query() const
|
|
||||||
{
|
{
|
||||||
Q_D(const QSqlQueryModel);
|
Q_D(const QSqlQueryModel);
|
||||||
return d->query;
|
return d->query;
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns information about the last error that occurred on the
|
Returns information about the last error that occurred on the
|
||||||
|
@ -46,7 +46,10 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
void setQuery(QSqlQuery &&query);
|
void setQuery(QSqlQuery &&query);
|
||||||
void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase());
|
void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase());
|
||||||
|
#if QT_SQL_REMOVED_SINCE(6, 5)
|
||||||
QSqlQuery query() const;
|
QSqlQuery query() const;
|
||||||
|
#endif
|
||||||
|
const QSqlQuery &query(QT6_DECL_NEW_OVERLOAD) const;
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user