Important: Please read the Qt Code of Conduct -

QTableWidget performance / GUI responsivenes

  • Dear friends,

    I am working on an object detection solution:

    1-Thread detection object and make calculation etc. Sending the results , pictures and the live stream video to the main thread GUI through signal / Slot mechanism.

    All working great but after 10 min main thread (GUI ) start to unresponsive.

    We are using QtableWidget to show pictures (150x150 pixel) each row , meta info text(80 char).

    worker thread sending very fast (4-7 pic/sec) signal sometimes.

    After a while 10 min or after 1000 rows gui looks unresponsive.

    What is your experince ? is this a good idea to use qtablewidget or some other solution suggested ?


  • @RahibeMeryem said in QTableWidget performance / GUI responsivenes:

    We are using QtableWidget to show pictures (150x150 pixel) each row

    Are you using setItemWidget? if so, that's your bottleneck. Store the images in the Qt::DecorationRole of the QTableWidget using setData. You can customise the appearance by reimplementing QStyledItemDelegate

  • Below the code that updates the QtableWidget ; data coming from the signal/Slot mechanism (QVariant type . include both QPix and text)

        QTableWidgetItem* item       = new QTableWidgetItem;
        QTableWidgetItem* item_cam   = new QTableWidgetItem;
        QTableWidgetItem* item_dist  = new QTableWidgetItem;
        QTableWidgetItem* item_notes = new QTableWidgetItem;
        item_cam->setData(Qt::DecorationRole, (metaTable.live_big_chip).scaledToWidth(150));

  • Lifetime Qt Champion


    Why are you disabling/enabling the updates every time you add new elements ? Basically you are asking for a full repaint every time you add data.

  • I did it because the tableWidget not updated realtime. The problem table updated with pix but not seen corrctly, when I mouse over it shows the updated pix. This is why I try dissable/enable.


  • Lifetime Qt Champion

    QTableWidget is a convenience class. If you need fast updates it's much better to use a QTableView and write a proper model.
    The update stuff including setUpdatesEnabled(false/true) is not needed at all and adjustToContents() will also slow down everything since it has to ask (nearly) every cell for it's width.
    When you have sorting enabled you should make sure to disable sorting before insertion ( see )

  • Thanks..

    It getting faster already and now all looks good.

    thx again.

  • Lifetime Qt Champion

    Good !

    Then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

Log in to reply