Qt widget for displaying large amount of data rows

左心房为你撑大大i 提交于 2019-11-30 15:24:23

If it's tabular data I would use a table. I would write a custom QTableView with a custom QAbstractTableModel. In the QTableView you have control of all visible items. I would put some kind of check or variable shared between QTableView and it's model to control how much data should be shown. By overriding the data method in QAbstractTableModel you can dictate how much data to show. You can also mess with the QTableView's scroll bar to make things look and feel nicer.

If you don't really care about editing or looks, you could use a simple QTextEdit/QTextBrowser that is set to read only.

Note: A QTableWidget with a custom model is somewhat pointless. The main difference between a QTableWidget and a QTableView is that the QTableWidget has it's own premade model.

Pavel Strakhov

Qt views are known to be slow on large data amounts. QTableWidget or QStandardItemModel cannot be used here because they create new object for each table item. That causes large overhead. You should start from implementing your own fast QAbstractItemModel subclass and showing it in a standard QTableView. It's possible that it will work acceptably fast. You can also try to set fixed row height for the view to speed things up.

If it won't work, you can try to implement your own table view. Also you can use Graphics View Framework as described in this answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!