2

I'm wondering if it is possible to have multiple views onto a common model, where each view's root index is an arbitrary index in the common model in Qt? Can this be achieved with a proxy model of some sort?

E.g.

source model:
root
 -A
   -1
   -2
 -B
   -3
   -4

Tree View:
 -A
   -1
   -2
 -B
   -3
   -4

List View1 (using index A as root):
 -1
 -2

List View2  (using index B as root):
 -3
 -4

Edit: So it seems the functionality I was trying to attain can be achieved by QTreeView.setRootIndex(). Unfortunately the QDeclarativeView doesn't offer this feature (yet?).

russdot
  • 625
  • 1
  • 7
  • 14

1 Answers1

2

Subclass QAbstractProxyModel and implement the mapTo.. and mapFrom.. methods so when the view's root is requested (an invalid QModelIndex) the desired root in the source model is returned.

cmannett85
  • 21,725
  • 8
  • 76
  • 119