Dear Qt masters,
I have the following very simple "model":
typedef QPair<QString,QStringList> EnumDefinition;
typedef QList<EnumDefinition> EnumDefinitionList;
EnumDefinitionList enumTypes;
// ... example:
enumTypes[0].first = "Boolean";
enumTypes[0].second[0] = "False";
enumTypes[0].second[1] = "True";
enumTypes[1].first = "Color";
enumTypes[1].second[0] = "Red";
enumTypes[1].second[1] = "Green";
enumTypes[1].second[2] = "Blue";
typedef QPair<QString,QStringList> EnumDefinition;
typedef QList<EnumDefinition> EnumDefinitionList;
EnumDefinitionList enumTypes;
// ... example:
enumTypes[0].first = "Boolean";
enumTypes[0].second[0] = "False";
enumTypes[0].second[1] = "True";
enumTypes[1].first = "Color";
enumTypes[1].second[0] = "Red";
enumTypes[1].second[1] = "Green";
enumTypes[1].second[2] = "Blue";
To copy to clipboard, switch view to plain text mode
Now I would like this to display in a tree view as:
- Boolean
+-- False
+-- True
- Color
+-- Red
+-- Green
+-- Blue
Can this be done using the QAbstractItemModel?
(I am a little confused about the mapping between QModelIndex
and the indexes in my EnumDefinitionList)
Many thanks,
Oliver
Bookmarks