Modify QSqlQueryModel roleNames
QSqlQueryModel::roleNames was exposing the default QAbstractItemModel roles. Only "display" role makes sense because it's a read-only model and it is not providing any other data information. [ChangeLog][Important Behavior Changes] The names of the roles returned by QSqlQueryModel::roleNames now only include a name for the Qt::DisplayRole. Previously all the roles names of QSqlQueryModel were returned. Task-number: QTBUG-60857 Change-Id: Ib18aa0e7083a828648767d700c5af05b6aa84f4f Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
9609e2945c
commit
40206a9f6d
@ -212,6 +212,30 @@ bool QSqlQueryModel::canFetchMore(const QModelIndex &parent) const
|
||||
return (!parent.isValid() && !d->atEnd);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.10
|
||||
\override
|
||||
|
||||
Returns the model's role names.
|
||||
|
||||
Qt defines only one role for the QSqlQueryModel:
|
||||
|
||||
\table
|
||||
\header
|
||||
\li Qt Role
|
||||
\li QML Role Name
|
||||
\row
|
||||
\li Qt::DisplayRole
|
||||
\li display
|
||||
\endtable
|
||||
*/
|
||||
QHash<int, QByteArray> QSqlQueryModel::roleNames() const
|
||||
{
|
||||
return QHash<int, QByteArray> {
|
||||
{ Qt::DisplayRole, QByteArrayLiteral("display") }
|
||||
};
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
void QSqlQueryModel::beginInsertRows(const QModelIndex &parent, int first, int last)
|
||||
|
@ -86,6 +86,8 @@ public:
|
||||
void fetchMore(const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE;
|
||||
bool canFetchMore(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
protected:
|
||||
void beginInsertRows(const QModelIndex &parent, int first, int last);
|
||||
void endInsertRows();
|
||||
|
Loading…
x
Reference in New Issue
Block a user