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. QListWidget performace
Forum Updated to NodeBB v4.3 + New Features

QListWidget performace

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 2.5k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bonve
    wrote on last edited by
    #1

    I need to clear and repopulate this widget many times

    first using:

    ui->resultList->clear();

    and then:

    ui->resultList->addItem(new QListWidgetItem(""));

    there is a noticeable performance degradation of addItem method after some clear calls

    1 Reply Last reply
    0
    • _ Offline
      _ Offline
      _compiler
      wrote on last edited by
      #2

      a perfectly normal working, no problem

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        -Perhaps you would have better luck with a QListView, rather than a QListWidget.-

        [Edit: On second thought, maybe not.]

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #4

          disable updates while clearing and repopulating. See setUpdatesEnabled

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bonve
            wrote on last edited by
            #5

            [quote author="mlong" date="1354218238"]Perhaps you would have better luck with a QListView, rather than a QListWidget.
            [/quote]

            I switchet to QlistView and I used this model class
            @
            #ifndef NETWORK_TESTS_RESULT_MODEL_H
            #define NETWORK_TESTS_RESULT_MODEL_H

            #include <QAbstractListModel>

            class QMimeData;

            class resultListModel : public QAbstractListModel
            {
            Q_OBJECT

            public:
            resultListModel(QObject *parent = 0);
            ~resultListModel();

             void addResult(const QString &postation);
             bool setData(const QModelIndex &index, const QVariant &val,int role);
             QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
             bool removeRows(int row, int count, const QModelIndex &parent);
             int rowCount(const QModelIndex &parent) const;
             void clear();
            

            private:
            QPixmap *IdIcon;
            QList<QString> *postationNames;
            QList<QString> *hardwareIds;
            QList<QPixmap> *hardwareImages;
            QList<QString> *hardwareNames;
            QList<QString> *results;
            };

            #endif // NETWORK_TESTS_RESULT_MODEL_H
            @
            unfortunately there is no improvements on performance

            now I'm trying to use setUpdatesEnabled

            thanks for help

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DerManu
              wrote on last edited by
              #6

              Using Qts Model-View-Classes for performance improvement usually requires you to write your own data model which takes into account the nature of your data to get the performance improvement. Sometimes you'll even want to write your own views. Of course, that's a non-trivial task. But if using off-the-shelf model-view components (especially Qts), you generally degrade performance (with the benefit of more flexibility and possibly a less entangled application design compared to the non-mvc approach).

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on last edited by
                #7

                I agree with DerManu.

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  bonve
                  wrote on last edited by
                  #8

                  thanks for replys Qt is a great work.
                  I changed strategy and now all works fine

                  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