Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTableWidget very slow
mrdebug last edited by
I need to insert in a qtablewidget 18000 rows and 50 columns.
I normally use MyTable->setCellWidget(QLabel)
but this requires a very long time and a very lot of memory.
Is there another way? I need to display only text.
use QTableView with a custom model (subclass QAbstractTableModel for example).
This should give you better results than with the overhead of the standard items.
With a dataset of such a high count of entries it also makes sense to think about the structure you use to store them and use for look up in the model!
To add to raven-worx, why are you using setCellWidget ?
andre last edited by
You are creaing 900.000 widget instances and trying to scroll all of them, and then you are surprised that that doesn't perform well?
I find that Q*Widget really are toy versions of the views, and IMnsHO they should not have been in Qt to begin with. Just use a custom model as suggested by raven-worx. It will perform much better. Note that an item view doesn't create widgets to display items. Instead, it renders only the items that actually need displaying.