Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Foo{
- int age;
- std::string name;
- }
- QVariant FooListModel::data(const QModelIndex &index, int role) const
- {
- if (index.row() < 0 || index.row() > fooList.count())
- return QVariant();
- const Foo & foo = contacts[fooList.row()];
- if (role == AgeRole) //AgeRole = 0
- return foo.age();
- else if (role == NameRole) //NameRole = 1
- return QString::fromStdString(foo.name());
- return QVariant();
- }
- struct Foo{
- int age;
- QString name;
- }
Add Comment
Please, Sign In to add comment