Sorry, sorry, my mistake. You need to implement the QAbstractItemModel::flags() method to return the correct set of flags for each item in your model. I was thinking of QTableWidgetItem, which does have a setFlags() method.
So your tree model should initially return flags without the Qt:: ItemIsEnabled bit set for parents whose children have not been populated. Once all of the children have been loaded, then your model can enable the parent index. I think emitting the dataChanged() signal will cause the view to request the new data and flags for the parent, or possibly just hovering the mouse over the parent item will cause the flags to be queried. You'll have to test that.
Bookmarks