Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QTableWidget performance / GUI responsivenes

    General and Desktop
    4
    8
    1932
    Loading More Posts
    • 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
      RahibeMeryem last edited by VRonin

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

      V 1 Reply Last reply Reply Quote 0
      • V
        VRonin @RahibeMeryem last edited by

        @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 Reply Quote 3
        • R
          RahibeMeryem last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 1
            • R
              RahibeMeryem last edited by

              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 Reply Quote 0
              • Christian Ehrlicher
                Christian Ehrlicher Lifetime Qt Champion last edited by

                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 has to stay free or it will die.

                1 Reply Last reply Reply Quote 4
                • R
                  RahibeMeryem last edited by

                  Thanks..

                  It getting faster already and now all looks good.

                  thx again.

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    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 Reply Quote 0
                    • First post
                      Last post