HI!
I have a list of descriptors. These descriptors are constantly changing data. I build the tree items in the model from these descriptors.
m_pMyTreeModel = new CMyTreeModel();
//
m_pMyTreeModel->initializeModel(m_listDescriptors);
//
m_pFilterModel = new CMySortFilterProxyModel(this);
//
m_pFilterModel->setSourceModel(m_pMyTreeModel);
//
m_pTree->setModel(m_pFilterModel);
m_pMyTreeModel = new CMyTreeModel();
//
m_pMyTreeModel->initializeModel(m_listDescriptors);
//
m_pFilterModel = new CMySortFilterProxyModel(this);
//
m_pFilterModel->setSourceModel(m_pMyTreeModel);
//
m_pTree->setModel(m_pFilterModel);
To copy to clipboard, switch view to plain text mode
Each descriptor is connected to the item that is created in the model. I am emitting the signals
layoutAboutToBeChanged()
layoutAboutToBeChanged()
To copy to clipboard, switch view to plain text mode
and
layoutChanged()
layoutChanged()
To copy to clipboard, switch view to plain text mode
in a timer so that the data is updated correctly in the view.
The problem is that the code gets very slow with few thousand items (3000+).
I tried to implement the functions for better performance:
bool hasChildren(const QModelIndex &parent) const;
bool canFetchMore(const QModelIndex &parent) const;
void fetchMore(const QModelIndex &parent);
To copy to clipboard, switch view to plain text mode
but get stuck with the
void fetchMore(const QModelIndex &parent);
To copy to clipboard, switch view to plain text mode
function. In this function i should create the tree items, but the problem is that i have no descriptors here to connect them to the tree items.
I don't know if this is the best approach to update the data in the model. I think that there is a better way to do this, but have no idea how.
Please help.
Bookmarks