PDA

View Full Version : QStandardItemModel to TableView



uygar
20th May 2011, 15:12
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?

wysota
21st May 2011, 00:17
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.

uygar
21st May 2011, 09:23
Can any body help me to find out in the mapToSource function if the item has isExpanded or not???

wysota
21st May 2011, 12:09
There is no concept of "expanded" items in the model. It's a feature of the view.

uygar
23rd May 2011, 07:57
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?

wysota
23rd May 2011, 15:43
And what is stopping you from doing that? QTreeView::isExpanded() returns information whether the view shows a particular index as expanded or not.

uygar
23rd May 2011, 16:36
The problem is i cant get the treeitem to the maptosource...

wysota
23rd May 2011, 23:52
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.