TodorBalabanski
28th November 2017, 12:02
Hello,
I have been working on a task where I should make a drop-down menu like a combo box. I want to set a QMenu to QPushbutton, which should contain a qtreeview. Let's assume we have the following QAbstractItemModel:
X
-->Leaf_B1
.....-->Leaf_B1.1
.....-->Leaf_B1.2
......... ------>Leaf_A1.1.1
-->Leaf_B2
.....-->Leaf_B2.1
......... ------->Leaf_B2.1.1
-->Leaf_B3
.....-->Leaf_B3.1
.....-->Leaf_B3.2
......... ------->Leaf_B2.1.1
I want to customize a QTreeView to look like QListView and to populate only second hierarchy elements in the view (Leaf_B1, Leaf_B2, Leaf_B3).
I have made a search about it on the web and I have stumble across the following article:
https://stackoverflow.com/questions/7563512/how-to-use-qsortfilterproxymodel-to-filter-a-tree-model-that-only-display-childr
http://lynxline.com/jongling-qt-models/
I have tried to use QTreeView::setRootIndex() but without success.
I cannot understand how exactly i can abstract only the second level hierarchy elements.
Does anyone have an idea how can I abstract only these elements and populate them in the view?
Any suggestions are highly appreciated!
Thanks in advance
I have been working on a task where I should make a drop-down menu like a combo box. I want to set a QMenu to QPushbutton, which should contain a qtreeview. Let's assume we have the following QAbstractItemModel:
X
-->Leaf_B1
.....-->Leaf_B1.1
.....-->Leaf_B1.2
......... ------>Leaf_A1.1.1
-->Leaf_B2
.....-->Leaf_B2.1
......... ------->Leaf_B2.1.1
-->Leaf_B3
.....-->Leaf_B3.1
.....-->Leaf_B3.2
......... ------->Leaf_B2.1.1
I want to customize a QTreeView to look like QListView and to populate only second hierarchy elements in the view (Leaf_B1, Leaf_B2, Leaf_B3).
I have made a search about it on the web and I have stumble across the following article:
https://stackoverflow.com/questions/7563512/how-to-use-qsortfilterproxymodel-to-filter-a-tree-model-that-only-display-childr
http://lynxline.com/jongling-qt-models/
I have tried to use QTreeView::setRootIndex() but without success.
I cannot understand how exactly i can abstract only the second level hierarchy elements.
Does anyone have an idea how can I abstract only these elements and populate them in the view?
Any suggestions are highly appreciated!
Thanks in advance