SGbo
SGbo

Reputation: 354

QTreeView does only update when Cursor is moved

I'm using a QTreeView to display data that is updated every second. Each Item in the View has a setData(QVariant value)-function that emit's a custom dataChanged(int index, QVariant value)-signal. When the items are inserted to the Model, the dataChanged()-Signal of the Item get's connected to a itemDataChanged()-Slot of the Model. This function calls the dataChanged()-Signal of the QAbstractItemModel.

When I now start the application, the QTreeView get's only updated when I move my Cursor over the QTreeView.

I already found someone else having the problem, but without a solution. Below are links, to a video of the effect and the original post from qtcentre.org.

http://www.qtcentre.org/threads/55490-QTreeView-unexpectedly-updates-on-mouse-movement-%28Win-Linux%29-or-focus-change-%28OSX%29

https://www.youtube.com/watch?v=1rVhB60VqBQ&feature=youtu.be

Upvotes: 4

Views: 798

Answers (1)

John Grabow
John Grabow

Reputation: 1

I'm using a QSortFilterProxyModel but it should work with your tree model. Just emit the dataChanged() signal with invalid model indicies like so:

dataChanged(QModelIndex(), QModelIndex());

This way no data is affected and the treeView refreshes.

Upvotes: 0

Related Questions