Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QAbstractItemView::dataChanged problem with ranges
When I emit a dataChanged with a topLeft index different from the bottomRight index, the view updates all cells.
Is there a reason for this?
andre last edited by
Different views use different rendering strategies, AFAIK. Views can use the information about the range to limit their rendering, but they are under no obligation to do so. What view are you using?
I'm using TableView. I have a lot of data updates, so I'm buffering the updates and, with a given interval, I emit the dataChanged for the topLeft until the bottomRight indexes of buffered data, but the model's data method is called for every cell. Emit a signal for every updated cell will have a performance penalty too. A range update would be the best choice, I think.
Jeroentjehome last edited by
Got myself the same problem. I update a QString list and want that QString list in a tableView (1 QString list per row), but how do I just update 1 row?
I found some tickets in QT's JIRA, one of them: QTBUG-13668. It seems this is the expected behavior, although I have some questions about it. I sow the source code of QAbstractItemView::dataChanged and there is a big difference handling topLeft == bottomRight and topLeft != bottomRight. In the first case only the cell with the given index is updated, in the second case, it passes the update responsibility to the viewport. For me this is a strange behavior, I would expect that the update was always handle by the viewport or always handled by QAbstractItemView and not distinguished if is only a cell or more.
I can see 2 solutions:
- Re-implement dataChanged method;
- Emit one signal for each cell.
Any other suggestion would be appreciated.