Qt Forum

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

    Forum Updated on Feb 6th

    QListWidget performace

    General and Desktop
    4
    8
    2069
    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.
    • B
      bonve last edited by

      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 Reply Quote 0
      • _
        _compiler last edited by

        a perfectly normal working, no problem

        1 Reply Last reply Reply Quote 0
        • M
          mlong last edited by

          -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 Reply Quote 0
          • D
            DerManu last edited by

            disable updates while clearing and repopulating. See setUpdatesEnabled

            1 Reply Last reply Reply Quote 0
            • B
              bonve last edited by

              [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 Reply Quote 0
              • D
                DerManu last edited by

                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 Reply Quote 0
                • M
                  mlong last edited by

                  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 Reply Quote 0
                  • B
                    bonve last edited by

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

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post