Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Empty rows in QSortFilterProxyModel

    General and Desktop
    1
    1
    775
    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.
    • L
      loki7 last edited by

      Hi folks,

      I'm using QSortFilterProxyModel to sort a custom model(inherit from QAbstractItemModel) which maintains a callstack tree. Data will dynamically inserted into this model by a custom interface called insert data(showed below).
      @
      void ProfModel::insertData(DWORD *stack, int depth, Counts counts)
      {
      ProfItem *curr = m_root_item;
      curr->modData(counts);

      ProfItem *tmp;
      for(int i=0; i<depth; i++)
      {
      tmp = curr->getChild(stack[i]);
      if(tmp == NULL)
      {
      beginInsertRows(createIndex(curr->row(), 0, curr),
      curr->childCount(), curr->childCount());
      for(int j=i; j<depth; j++)
      {
      tmp = curr->createChild(stack[j]);
      tmp->modData(counts);
      m_queue->addParse(tmp);
      curr = tmp;
      }
      endInsertRows();
      return;
      }
      else
      {
      tmp->modData(counts);
      curr = tmp;
      }
      }
      }
      @

      Everything goes as expected if I directly display my custom model into a QTreeView. But when I display my model through a QSortFilterProxyModel, randomly there were some empty rows inserted in the treeview. I'm sure that these empty rows are not exist in my custom model.

      I've tried Qt4.7 and Qt4.8, but both of them came out with the same result.

      Can anyone help me with this?

      Thanks in advance.

      Best

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