I have created my own data model derived from QAbstractItemModel. The model is used to store communication trace data row by row. A row holds the data of an inbound or outbound packed. The packet's information is split across different columns such as 'Timestampt', 'Source', 'Destination' etc. The row buffer has a configurable size and if it gets full the oldest row (the first in the model) is discarded and the new row gets appended (as last row). To display the data I use QTreeView.
Things are working fine but the performance is poor. When I use more then 10 rows scrolling is very slow and the processor load is somewhere between 35% to 80%!
My data model implements the following methods from QAbstractItemModel:
- columnCount
- rowCount
- index
- parent
- data;
- headerData
My own method 'AppendRow' to add a row of trace information uses 'beginInsertRows' and 'endInsertRows' to do the job.
I am pretty sure that I missed something very important in my implementation of the sublassed QAbstractItemModel but I just can't imagine what and where the performance lost comes from. Using gprof I found that the method 'data' uses up most of the time but I think this is quite logic and correct as it is the method called over and over again from the view to get information about what to display, right?
So, what did I really miss? Can anybody give me a hint?
Many thanks Felix
Bookmarks