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. QTableview appending data is slow
Qt 6.11 is out! See what's new in the release blog

QTableview appending data is slow

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.4.1qtableview
7 Posts 2 Posters 4.4k 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.
  • A Offline
    A Offline
    anandvivek
    wrote on last edited by
    #1

    I have mdi sub sub window, I can able to create multiple instance for the mdi sub window. Inside sub window I have QTableview, I am continuously appending data to the QTableview. If I open 4 or more than 4 sub windows and keep on appending data to all the windows, my application and data appending to the tableview is very slow. Please help me to solve this problem.
    Thanks in advance.

    raven-worxR 1 Reply Last reply
    0
    • A anandvivek

      I have mdi sub sub window, I can able to create multiple instance for the mdi sub window. Inside sub window I have QTableview, I am continuously appending data to the QTableview. If I open 4 or more than 4 sub windows and keep on appending data to all the windows, my application and data appending to the tableview is very slow. Please help me to solve this problem.
      Thanks in advance.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @anandvivek said:

      Please help me to solve this problem.

      how should that be possible by these few lines of written text which basically just say no more than "i have a problem. help me"
      When the appending is slow by your opinion, then show the code of it or at least describe what you are doing in detail...

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • A Offline
        A Offline
        anandvivek
        wrote on last edited by
        #3

        Whenever I am going to create sub window, I am creating object for the sub window.
        EzSubWindow *busDirectSubWindow;
        busDirectSubWindow = new EzBusDirectSubWindow(spaDocument, fileName,this);

        Inside this class I have connect signal to table model. I'm using tableview and setWidget(tableview) to busdirectsubwindow class.

        connect(this, SIGNAL(canFramesReceived(QVector<QStringList>)), _tableModel,SLOT(append(QVector<QStringList>)));
        

        If I'm getting data from device I will add the data to QVector<QstringList> variable and emit as a signal to the table model append slot.

        void EzTableModel::append(QVector<QStringList> data)
        {
        int removeRowCount = 0;
        int newRowCount = _rowCount + data.size();

        if (newRowCount > _maxRowCount) {
        removeRowCount = newRowCount - _maxRowCount;

        beginRemoveRows(QModelIndex(), 0, removeRowCount - 1);
        _data.remove(0, removeRowCount);
        newRowCount -= removeRowCount;
        endRemoveRows();
        

        }

        beginInsertRows(QModelIndex(), _rowCount - removeRowCount, newRowCount - 1);
        _data += data;
        _rowCount = newRowCount;
        endInsertRows();
        }

        This whole thing will happen for every sub window creation and reading data from device also separate for every window.
        This is my scenario. If I open multiple windows and run all the windows data appending and displaying data is getting slow.

        raven-worxR 1 Reply Last reply
        0
        • A anandvivek

          Whenever I am going to create sub window, I am creating object for the sub window.
          EzSubWindow *busDirectSubWindow;
          busDirectSubWindow = new EzBusDirectSubWindow(spaDocument, fileName,this);

          Inside this class I have connect signal to table model. I'm using tableview and setWidget(tableview) to busdirectsubwindow class.

          connect(this, SIGNAL(canFramesReceived(QVector<QStringList>)), _tableModel,SLOT(append(QVector<QStringList>)));
          

          If I'm getting data from device I will add the data to QVector<QstringList> variable and emit as a signal to the table model append slot.

          void EzTableModel::append(QVector<QStringList> data)
          {
          int removeRowCount = 0;
          int newRowCount = _rowCount + data.size();

          if (newRowCount > _maxRowCount) {
          removeRowCount = newRowCount - _maxRowCount;

          beginRemoveRows(QModelIndex(), 0, removeRowCount - 1);
          _data.remove(0, removeRowCount);
          newRowCount -= removeRowCount;
          endRemoveRows();
          

          }

          beginInsertRows(QModelIndex(), _rowCount - removeRowCount, newRowCount - 1);
          _data += data;
          _rowCount = newRowCount;
          endInsertRows();
          }

          This whole thing will happen for every sub window creation and reading data from device also separate for every window.
          This is my scenario. If I open multiple windows and run all the windows data appending and displaying data is getting slow.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @anandvivek
          first of all it should never possible that in your append() method the row count may decrease?!

          This should be enough:

          void EzTableModel::append(const QVector<QStringList> & appendData)
          {
          int count = _data.size();
          beginInsertRows(QModelIndex(), count, count + appendData.size() - 1);
          _data += appendData;
          endInsertRows();
          }
          

          But your problem is probably somewhere else.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • A Offline
            A Offline
            anandvivek
            wrote on last edited by
            #5

            Thanks for your suggestion. I will try to find the problem from where it is coming.

            raven-worxR 1 Reply Last reply
            0
            • A anandvivek

              Thanks for your suggestion. I will try to find the problem from where it is coming.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @anandvivek
              try removing small parts of your application step by step as good as possible to pin down the issue.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • A Offline
                A Offline
                anandvivek
                wrote on last edited by
                #7

                Sure. Thanks .

                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