Guest User

Untitled

a guest
Jul 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. struct Foo{
  2. int age;
  3. std::string name;
  4. }
  5.  
  6. QVariant FooListModel::data(const QModelIndex &index, int role) const
  7. {
  8. if (index.row() < 0 || index.row() > fooList.count())
  9. return QVariant();
  10. const Foo & foo = contacts[fooList.row()];
  11. if (role == AgeRole) //AgeRole = 0
  12. return foo.age();
  13. else if (role == NameRole) //NameRole = 1
  14. return QString::fromStdString(foo.name());
  15. return QVariant();
  16. }
  17.  
  18. struct Foo{
  19. int age;
  20. QString name;
  21. }
Add Comment
Please, Sign In to add comment