Results 1 to 14 of 14

Thread: Need to show SQL data in tree view with lazy loading.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need to show SQL data in tree view with lazy loading.

    Your canFetchRow() still makes no sense. Lines #17-18 say "If you are asking about top-level items, I always have more of them". The error you are getting is probably related rather to an invalid implementation of index() rather than fetch-more.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Need to show SQL data in tree view with lazy loading.

    Finally I could do lazy loading, but not as I expected.

    I am reading X amount of rows and building parent and child relationship. as we keep on scroll down I am getting remaining data by using canFetchMore() and fetchMore() functions.
    once I get the data I am appending this data to existing data by forming parent and child relationship.

    1. The 1st problem is, I am not able to delete the old data, If I tried to delete old data and keep only new data I am not able to see any scroll bars.
    2. the 2nd problem is when I have huge data, As the user keep on scroll down, scroll bar is becoming small. if we have a huge amount of data it becoming difficult for the user to really go to the end of the view and wait for the result to fetch and once results got fetched then come to know that there are some more records are available and still scroll down.

    for the second problem I tried to create vertical scroll bar and set a value for it and then set it to the view. but It did not workout.
    could you please suggest some solution for this 2 problems.




    Below is the code snippet, please suggest how to delete old data and maintain only current records in a memory.


    Qt Code:
    1. bool TreeModel::canFetchMore(const QModelIndex &parent ) const
    2. {
    3. if(m_totalRowCount > m_lastFetchedRowNumber)
    4. {
    5. return true;
    6. }
    7.  
    8. return false;
    9. }
    10.  
    11. void TreeModel::fetchMore(const QModelIndex& parent)
    12. {
    13. int readRows = 1000; //reading 1000 records/rows every time
    14.  
    15. if( m_totalRowCount < ( readRows + m_lastFetchedRowNumber ) ) //boundary condition
    16. {
    17. readRows = m_totalRowCount - m_lastFetchedRowNumber;
    18. }
    19.  
    20. qint64 l_lastInsertedRow = m_lastreadRowIndex;
    21.  
    22.  
    23.  
    24. //m_parent is my parent, I tried by doing this; delete m_parrent; m_parrent = createParentItem(); // but it did not workout.
    25.  
    26.  
    27. emit fetchMoreData(readRows); // will fetch readRows no.of rows, may vary depends on logic(next fetch would start from a row which Level is 0) I have written.
    28.  
    29. // I have written a logic so that every time I will get 0 as 1st row, so every time I insert data, parent must me QModelIndex()
    30.  
    31. beginInsertRows(QModelIndex(), l_lastInsertedRow, m_lastreadRowIndex-1);
    32. endInsertRows();
    33.  
    34. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need to show SQL data in tree view with lazy loading.

    Quote Originally Posted by DURGAPRASAD NEELAM View Post
    1. The 1st problem is, I am not able to delete the old data, If I tried to delete old data and keep only new data I am not able to see any scroll bars.
    2. the 2nd problem is when I have huge data, As the user keep on scroll down, scroll bar is becoming small. if we have a huge amount of data it becoming difficult for the user to really go to the end of the view and wait for the result to fetch and once results got fetched then come to know that there are some more records are available and still scroll down.

    for the second problem I tried to create vertical scroll bar and set a value for it and then set it to the view. but It did not workout.
    could you please suggest some solution for this 2 problems.
    Your model needs to report its full size to the caller but it doesn't mean you have to actually have all the data at hand. As I said before you can use e.g. QContignousCache.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Need to show SQL data in tree view with lazy loading.

    Hi, Could you please help me out for this :

    http://www.qtcentre.org/threads/6232...281#post276281

Similar Threads

  1. table view and tree view
    By MKSPulok in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2012, 21:48
  2. Replies: 1
    Last Post: 3rd October 2011, 15:40
  3. How to map tree model data to list view
    By msopanen in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2009, 19:56
  4. data, model and tree view
    By larry104 in forum Qt Programming
    Replies: 17
    Last Post: 3rd July 2006, 14:43
  5. Model, view, resize to show all data
    By jcr in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2006, 20:59

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.