Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTableWidget performance / GUI responsivenes
Forum Update on Monday, May 27th 2025

QTableWidget performance / GUI responsivenes

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by VRonin
    #1

    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 ?

    thanks..

    VRoninV 1 Reply Last reply
    0
    • R RahibeMeryem

      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 ?

      thanks..

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3
      • R Offline
        R Offline
        RahibeMeryem
        wrote on last edited by
        #3

        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->setData(Qt::DecorationRole,metaTable.db_found_obj);
            item_cam->setData(Qt::DecorationRole, (metaTable.live_big_chip).scaledToWidth(150));
        
            item_notes->setText(metaTable.db_obj_notes);
            item_dist->setText(metaTable.db_found_obj_name);
        
            setUpdatesEnabled(false);
        
            ui->tableWidget->horizontalHeader()->AdjustToContents;
            ui->tableWidget->insertRow(0);
        
            ui->tableWidget->setItem(0,0,item);
            ui->tableWidget->setItem(0,1,item_cam);
            ui->tableWidget->setItem(0,2,item_dist);
            ui->tableWidget->setItem(0,3,item_notes);
            row_count++;
        
            setUpdatesEnabled(true);
        
            QWidget::update();
            ui->tabWidget->repaint();
            qApp->processEvents();
        
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • R Offline
            R Offline
            RahibeMeryem
            wrote on last edited by
            #5

            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.

            :)

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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 http://doc.qt.io/qt-5/qtablewidget.html#details )

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              4
              • R Offline
                R Offline
                RahibeMeryem
                wrote on last edited by
                #7

                Thanks..

                It getting faster already and now all looks good.

                thx again.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  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 :)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved