PDA

View Full Version : QTreeView unexpectedly updates on mouse movement (Win/Linux) or focus change (OSX)



kubark42
20th July 2013, 21:07
We have a QTreeView that is linked to a data model, but there is no datachanged() signal being expressly sent to a subclassed QTreeView. Nonetheless, it updates the view under certain circumstances. With Linux and Windows, it updates when the mouse moves across the widget. With Mac OSX it updates when the focus is changed.

There is no logic in our subclass which follows the mouse movement or the window focus. Is this a bug in our software, a Qt bug, or a Qt feature which we simply aren't understanding?

Here's a video of the behavior on Windows/Linux:

http://youtu.be/1rVhB60VqBQ

P.S. Using Qt 4.8.4.

ChrisW67
21st July 2013, 04:28
Is this a bug in our software, a Qt bug, or a Qt feature which we simply aren't understanding?
I would bet on option 1.

It looks like something is changing the QItemSelectionModel of the view, not the model.

kubark42
21st July 2013, 04:37
Thanks for the tip. I went looking and found that we're using a subclass of QAbstractItemModel, but I assume that this would have the same effect.

Is there any extra info you could add, such as the command itself that would be changing the model?

ChrisW67
21st July 2013, 23:46
Anything in your code that touches QTreeView::setSelectionModel(), selectionModel() or subclasses QItemSelectionModel would be a suspect. If you do not replace the selection model of the view then this is unlikely to be the cause.

If you have a totally hand-written model then it is also possible that the model's return for Qt::BackgroundRole is changing possibly without setData() emitting dataChanged() reliably.