I have a TreeModel
which has some data loaded in it. There is a radio button in my application, which when clicked should update the TreeModel
with a new data.
I have tried the following things on switching the radio button and none is working:
emit
layoutChanged
emit layoutChanged();
emit
dataChanged
emit dataChanged(QModelIndex(), QModelIndex());
Referenced from:
What does 'bottomRight' mean when using dataChanged() with a QTreeView in Qt?
Recursively visiting each node in the tree and emitting dataChanged
void TreeView::getLastExpandedState(const QModelIndex& parent) { bool isExpand = isExpanded(parent); if (!isExpand) { return; } int rows = model()->rowCount(parent); for (int rowNum = 0; rowNum < rows ; ++rowNum) { QModelIndex childIndex = model()->index(rowNum, 0, parent); model->emitChange(parent,childIndex); getLastExpandedState(childIndex); } } void TreeModel::emitChange(const QModelIndex& parent,const QModelIndex& childIndex) { emit dataChanged(parent,childIndex); }
How to solve that?