Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

QTableWidget very slow



  • 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.


  • Moderators

    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!


  • Lifetime Qt Champion

    Hi,

    To add to raven-worx, why are you using setCellWidget ?



  • 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.


Log in to reply