tntcoda
2nd June 2009, 23:02
Hi,
I'm trying to update a QTreeView control when data inside its model is changed. I don't mean edited from the control directly, but instead either changed or added to the model from another point in the program.
So in my QAbstractTreeModel I have
void queue::addJob(...)
{
...
// Update model data
QModelIndex x = this->index(jobs.size(), 0, QModelIndex());
QModelIndex y = this->index(jobs.size(), 5, QModelIndex());
// Update the new row
emit dataChanged(x, y);
}
This however does nothing when data is added to the model. I have implemented: rowCount(), columnCount(), headerData() and data().
Please could someone tell me what im doing it wrong, do I have to implement setData()? Do I have to call insertRows() to add a new row, or does rowCount do this job for me? :confused:
emit reset() works, but thats clearly an inefficient approach with lots of data.
Many thanks,
Jack
I'm trying to update a QTreeView control when data inside its model is changed. I don't mean edited from the control directly, but instead either changed or added to the model from another point in the program.
So in my QAbstractTreeModel I have
void queue::addJob(...)
{
...
// Update model data
QModelIndex x = this->index(jobs.size(), 0, QModelIndex());
QModelIndex y = this->index(jobs.size(), 5, QModelIndex());
// Update the new row
emit dataChanged(x, y);
}
This however does nothing when data is added to the model. I have implemented: rowCount(), columnCount(), headerData() and data().
Please could someone tell me what im doing it wrong, do I have to implement setData()? Do I have to call insertRows() to add a new row, or does rowCount do this job for me? :confused:
emit reset() works, but thats clearly an inefficient approach with lots of data.
Many thanks,
Jack