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. incremental loading in table view without canFetchMore() and fetchMore()

incremental loading in table view without canFetchMore() and fetchMore()

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 330 Views 2 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.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    i'm using a library which is based on qt.
    the library has a table model/view implementation.
    i need incremental populating for my table. however they do not have canFetchMore() and fetchMore() implemented.

    in what ways can i implement lazy loading anyways?

    one option i could think of was this:
    i have the following variables: chunkRows - i want to retrieve this many rows at a time, m_currRowCount - the number of row currently loaded

    1. set initial row count = chunkRows
    2. in data() i do this check:
    if (index.row() + chunkRows >= m_currRowCount)
        m_currRowCount += chunkRows;
    
    ...
    return the data;
    

    this approach doesn't work. in my table i get only the first chunkRows items.

    please help :(

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you mean by "they do not have" ?
      What kind of model are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      U 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        What do you mean by "they do not have" ?
        What kind of model are you using ?

        U Offline
        U Offline
        user4592357
        wrote on last edited by
        #3

        @SGaist
        i mean if those methods were implemented, i could make use of those for implementing lazy loading.
        the model is derived from QAbstractTableModel, this is a part of data(), where m_pModel is a vector of vectors:

        QVariant TableModel::data(const QModelIndex& index, int role) const
        {
        	int nRow = index.row();
        	int nCol = index.column();
        	if (nRow < 0 || nRow >= m_pModel->getRowCount() || nCol < 0 || nCol >= m_pModel->getColumnCount())
        		return QVariant();
        
        	if (role == Qt::DisplayRole)
        	{
        		QString sStr;
        		m_pModel->getText(nRow, nCol, sStr);
        		return sStr;
        	}
                ....
        

        i tried to increase the row count in m_pModel->getRowCount() implementation, but i guess the problem why that idea doesn't work is that the actual data isn't called for those increased rows, therefore, m_pModel->getText() isn't called either.

        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