aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/models/abstractitemmodel/model.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/models/abstractitemmodel/model.cpp')
-rw-r--r--examples/quick/models/abstractitemmodel/model.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/quick/models/abstractitemmodel/model.cpp b/examples/quick/models/abstractitemmodel/model.cpp
index 9c24decf2d..524ed5461b 100644
--- a/examples/quick/models/abstractitemmodel/model.cpp
+++ b/examples/quick/models/abstractitemmodel/model.cpp
@@ -54,16 +54,10 @@ QString Animal::size() const
return m_size;
}
-//![0]
AnimalModel::AnimalModel(QObject *parent)
: QAbstractListModel(parent)
{
- QHash<int, QByteArray> roles;
- roles[TypeRole] = "type";
- roles[SizeRole] = "size";
- setRoleNames(roles);
}
-//![0]
void AnimalModel::addAnimal(const Animal &animal)
{
@@ -88,3 +82,12 @@ QVariant AnimalModel::data(const QModelIndex & index, int role) const {
return QVariant();
}
+//![0]
+QHash<int, QByteArray> AnimalModel::roleNames() const {
+ QHash<int, QByteArray> roles;
+ roles[TypeRole] = "type";
+ roles[SizeRole] = "size";
+ return roles;
+}
+//![0]
+