2

I implemented my own QAbstractItemModel (for TreeView) and override the setData method, that changes many childrens.

  • If I fire one "dataChanged" signal on a big view it is very slow and the ui freezes.
  • If I uncomment the signal, it is really fast, but I must interact with the ui (because model did not notify view).
  • If I break the Model/View concept, and call the hide and then show method on the TreeView it is fast and all changes are displayed ...

Why does hide/show call work?

Why is the datachanged Signal so slow?

firstIndex = idx.parent().child(firstChangedIndex.row(), 0)
self.dataChanged.emit(firstIndex, firstIndex)

firstChangedIndex = highest parent, that changes, but maybe not column 2

Eike Pierstorff
  • 31,996
  • 4
  • 43
  • 62
Dragonfire
  • 31
  • 3
  • How many items are in the tree? Did you set any options on the tree? What Qt version is that, on what *exact* platform (OS version, compiler version, # of bits)? It would help if you could create a small, [self contained example](http://www.sscce.org) that generates a dummy tree of similar size, and fires the signal. – Kuba hasn't forgotten Monica Mar 12 '14 at 13:51
  • PyQt 4.8.4 on Python 2.6, uniformRowHeights = True, example on the way ... – Dragonfire Mar 12 '14 at 14:03
  • Great! I will profile it and see where it gets bogged down. – Kuba hasn't forgotten Monica Mar 12 '14 at 14:07
  • As I told in some other answers, there is a hack for QTreeView. You should pass invalid indexes to `dataChanged`. C++ code is `emit dataChanged( QModelIndex(), QModelIndex() );` – Dmitry Sazonov Mar 12 '14 at 14:23
  • `datachanged` with invalid QModelIndex not solving my problem... and I can't reproduce it with a little example, so I must check my implementation ... [little_example](http://pastebin.com/nCK10tE3) – Dragonfire Mar 12 '14 at 14:36

1 Answers1

1

I found my mistake ... The Trolltech modelest was enabled ... Thanks for the hint with the invalid QModelIndex ... work very well

Dragonfire
  • 31
  • 3