ItemView (QTreeView and QTableView)

  • Hi there I have one Model having lot of data, I want to show this model in TreeView, model has Ten Node and four child node for each Ten node, I can show this in my treeview but now I want to show all child node in QtableView I dont know how to do it, I see pple suggest using proxy but can there be any other way without using proxymodel?
    I just want to show a subset of the model in my tableview please help

  • If you only want to show the children of a particular node of the tree then setting the tree model on the QTableView and setting QTableView::setRootIndex() to the index of the parent node should do it.

  • it works partially, I want to show all the child of the node in column but is showing all the child as Row
    like i RootNode A having 4 child my table after setting rootIndex as rootNode is showing all four child as 4 rows of one column, how can I show that as one row of 4 column?

  • You will need a proxy model to transpose rows for columns. Here's an example for a strictly tabular model that you may be able to use as a starting point:

  • ChrisW: Thanx for this link I will try this

  • Note that it won't work out of the box, as the model you're trying to transpose is (part of a) tree, not a table. So, you'll need to adapt the proxy to basically also get a setRootIndex, and only transpose anything under that index.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.