QStandardItemModel to TableView
Dear All
I have QStandardItemModel which has several leafs. Like
A
-A1
-A2
B
-B1
--B11
--B12
-B2
--B21
+C
+D
-E
-E1
What i would like to do is i want to create a table with these values like
A
A1
A2
B
B1
B11
B12
B2
B21
C
D
E
E1
I have search the from and see that people sugested QAbstractProxyModel but except the TransposeProxyModel i wasnt able to find anything. C
Can you please help me?
Re: QStandardItemModel to TableView
You need to implement a proxy model that will flatten your model. If item A has children A1 and A2, they have to be moved below their parent. Thus the row number of B' will increase by the number of children A has, etc.
Re: QStandardItemModel to TableView
Can any body help me to find out in the mapToSource function if the item has isExpanded or not???
Re: QStandardItemModel to TableView
There is no concept of "expanded" items in the model. It's a feature of the view.
Re: QStandardItemModel to TableView
Dear Wysota
What i am trying to do is, from the tree view, i would like to get the expaned items in the maptosource function?
Re: QStandardItemModel to TableView
And what is stopping you from doing that? QTreeView::isExpanded() returns information whether the view shows a particular index as expanded or not.
Re: QStandardItemModel to TableView
The problem is i cant get the treeitem to the maptosource...
Re: QStandardItemModel to TableView
You can store a pointer to the tree in the proxy model and then retrieve and use it in mapToSource and mapFromSource if you really have to.