Quote Originally Posted by wysota View Post
Are you sure form0 is defined for every object in the model? Can you prepare a minimal compilable example reproducing the problem?
Element:

Qt Code:
  1. class IrregularVerb : public QObject
  2. {
  3. Q_OBJECT
  4. Q_PROPERTY(QString form0 READ getForm0 NOTIFY formChanged)
  5. Q_PROPERTY(QString form1 READ getForm1 NOTIFY formChanged)
  6. Q_PROPERTY(QString form2 READ getForm2 NOTIFY formChanged)
  7. public:
  8. QString forms[3];
  9. QString getForm0() const { return getForm(0); }
  10. QString getForm1() const { return getForm(1); }
  11. QString getForm2() const { return getForm(2); }
  12. IrregularVerb(QString a, QString b, QString c) { forms[0] = a; forms[1] = b; forms[2] = c; }
  13. protected:
  14. const QString& getForm(const int& ind) const { return forms[ind]; }
  15. signals:
  16. void formChanged();
  17. };
To copy to clipboard, switch view to plain text mode 

Container for elements:
Qt Code:
  1. class german : public QList<QObject*>
  2. {
  3. public:
  4. german();
  5. };
  6.  
  7. german::german()
  8. {
  9. append(new IrregularVerb("anfangen", "fing an", "angefangen")); // and so on
  10. }
To copy to clipboard, switch view to plain text mode 

Class managing the containers:

Qt Code:
  1. class IrregularListWrapper : public QObject
  2. {
  3. Q_OBJECT
  4. Q_PROPERTY(QList<QObject*> db READ getdb NOTIFY langChanged)
  5. Q_ENUMS(Language)
  6. public:
  7. enum Language
  8. {
  9. English = 0,
  10. German = 1
  11. };
  12.  
  13. IrregularListWrapper() : db(0) { setLang(German); }
  14. ~IrregularListWrapper() { delete db; }
  15. QList<QObject*> getdb() const { return *db; }
  16.  
  17. Q_INVOKABLE void changeLang(Language l) { delete db; setLang(l); }
  18.  
  19.  
  20. signals:
  21. void langChanged();
  22. protected:
  23. void setLang(Language);
  24. QList<QObject*> * db;
  25. };
  26.  
  27. void IrregularListWrapper::setLang(Language l)
  28. {
  29. switch (l)
  30. {
  31. case English:
  32. db = new english;
  33. langName = "English";
  34. break;
  35. case German:
  36. db = new german;
  37. langName = "German";
  38. break;
  39. }
  40. emit langChanged();
  41. }
To copy to clipboard, switch view to plain text mode 

ListView:

Qt Code:
  1. ListView
  2. {
  3. id: irrview
  4. width: parent.width
  5. model: irregulars.db
  6. anchors.top: caption.bottom
  7. anchors.bottom: parent.bottom
  8. spacing: 5
  9. clip: true
  10. section.criteria: ViewSection.FirstCharacter
  11. section.property: "form0"
  12. section.delegate: Item {height: 10; width: parent.width; Text { text: section } }
  13. delegate: Rectangle
  14. {
  15. height: 60
  16. width: parent.width
  17. color: "#E0E1E2"
  18. Row
  19. {
  20. height: parent.height
  21. width: parent.width - 10
  22. anchors.horizontalCenter: parent.horizontalCenter
  23. property real columnWidth: (width - 10) / 3
  24. property int rad: 10
  25. spacing: 5
  26. Rectangle
  27. {
  28. height: parent.height
  29. width: parent.columnWidth
  30. radius: parent.rad
  31. Text
  32. {
  33. anchors.centerIn: parent
  34. text: modelData.form0
  35. }
  36. }
  37. Rectangle
  38. {
  39. height: parent.height
  40. width: parent.columnWidth
  41. radius: parent.rad
  42. Text
  43. {
  44. anchors.centerIn: parent
  45. text: modelData.form1
  46. font.pointSize: 24
  47. }
  48. }
  49. Rectangle
  50. {
  51. height: parent.height
  52. width: parent.columnWidth
  53. radius: parent.rad
  54. Text
  55. {
  56. anchors.centerIn: parent
  57. text: modelData.form2
  58. }
  59. }
  60. }
  61. }
  62. }
To copy to clipboard, switch view to plain text mode 

All the forms (form0, form1, form2) are displayed in teh ListView, and all the model elements are displayed.
If there's too much code, let me know