diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp index 864c5b99468..b9c7c3993a2 100644 --- a/src/sql/models/qsqlquerymodel.cpp +++ b/src/sql/models/qsqlquerymodel.cpp @@ -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 QSqlQueryModel::roleNames() const +{ + return QHash { + { Qt::DisplayRole, QByteArrayLiteral("display") } + }; +} + /*! \internal */ void QSqlQueryModel::beginInsertRows(const QModelIndex &parent, int first, int last) diff --git a/src/sql/models/qsqlquerymodel.h b/src/sql/models/qsqlquerymodel.h index f786f713005..b773b904751 100644 --- a/src/sql/models/qsqlquerymodel.h +++ b/src/sql/models/qsqlquerymodel.h @@ -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 roleNames() const override; + protected: void beginInsertRows(const QModelIndex &parent, int first, int last); void endInsertRows();