How to show the leaf nodes of a treemodel in a listview?



  • now, I come across a problem.

    1. I have a treeview and one treemodel(I use QStandardItemModel) correspondingly. The hierarchy may look like this:
      A
      -A1
      --A11
      ---A111
      -A2
      --A21
      --A22
    2. I have another view which is a listview.
      And I want to show the corresponding leaf nodes under which the user clicked.
      e.g. when the node A2 is clicked, the listview should show A21 and A22, and when A, it shows A111, A21 and A22.
      Is there any solution to this problem?
      And I use QSortFilterProxyModel and the function filterAcceptsRow, but it seams that when dealing with A2 that i return false, A21 and A22 wouldn't be called by filterAcceptsRow() any more.
      Please help me.


  • You can try the following:

    @
    connect(myTreeView, SIGNAL(activated(QModelIndex)),
    myListView, SLOT(setRootIndex(QModelIndex)));
    @



  • [quote author="Arnold Konrad" date="1368185773"]You can try the following:

    @
    connect(myTreeView, SIGNAL(activated(QModelIndex)),
    myListView, SLOT(setRootIndex(QModelIndex)));
    @[/quote]

    It won't work, because in the above case, when the A is clicked, the listview will get A1,A2 but not A111,A21,A22.


Log in to reply
 

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