Skip to content
  • How to dynamically add nodes to a QtreeView

    Unsolved General and Desktop how to dynamica
    4
    1 Votes
    4 Posts
    4k Views
    A
    @Qt-Enthusiast Ok so I used QStandardItemModel as an example, obviously adapt to your model. :) As for expanding only small "a" and "d", you add that to your expanded() function logic. You get the QModelIndex and then you can just check if it is the one you need to populate or not.. Something like: void MyWidget::somethingExpanded(const QModelIndex &index) { if (myModel->myItemName(index) == "a" || myModel->myItemName(index) == "d") { // add your items to your model here } }