Results 1 to 7 of 7

Thread: canFetchMore is getiing called 3 times ??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: canFetchMore is getiing called 3 times ??

    Thanks but, I did not mentioned anywhere that I am fetching data in canfectMore().
    Not directly but you say the view calls canFetchMore() three times and...
    My prob : lets say I wanted to get top 100 items & form tree out of it, because of above behavior I am ending up with 3*100 (buffer size) items.
    That is, calling canFetchMore() three times results in 3 times the number of rows fetched in the model. You did not say that the view calls fetchMore() 3 times. If you had done that, then you would have been describing correct and expected operation. I assumed that you were describing unexpected behaviour. One obvious way that unexpected row fetching might happen is if canFetchMore() actually fetched rows.
    Problem is that canFetchMore() is calling 3 times when it supposed to call 1 time.
    No, you would like it to only call canFetchMore() once but that is not a requirement on the view, just an assumption on your part.
    If canFetchMore() returns true then the view can call fetchMore() if it wants, and the correct behaviour of the model is to fetch more rows. The view will fetch rows as it requires and probably in some convenient quantity for its internal buffering/performance/rendering purposes (i would guess 256 rows if the sql model is anything to go by). If you do not like this behaviour then you are free to implement your own view.

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 14 Times in 14 Posts

    Default Re: canFetchMore is getiing called 3 times ??

    Quote Originally Posted by ChrisW67 View Post
    If canFetchMore() returns true then the view can call fetchMore() if it wants, and the correct behaviour of the model is to fetch more rows. The view will fetch rows as it requires and probably in some convenient quantity for its internal buffering/performance/rendering purposes (i would guess 256 rows if the sql model is anything to go by).
    - I understand that because of view internal calls, canFetchMore() is getting called more than once (3 times in my case even if I return false from canfetch() or even if view is full with Items)
    - After some experiments I came to know that header data is one which causes canFetchMore() to be called (When we change headerData dynamically its calling canFetchMore() ),
    so I decided to have customized model & View for my header & It worked out Now when ever I expand an item (or when canFetchMore() supposed be called by view) instead of 3 times its getting called 2 times.
    - now its getting called twice as follows when I expand a item

    canFectMore Called with parent = QModelIndex(0,0,0xd00870,DebugTreeModel(0xcf4ec0) ) //one for the expanded Item as parent
    canFectMore Called with parent = = QModelIndex(-1,-1,0x0,QObject(0x0) ) //One for root item
    this might be of other reason like header data.

    Quote Originally Posted by ChrisW67 View Post
    If you do not like this behaviour then you are free to implement your own view.
    could let me know which functions I have to re implement for this in view ??
    Last edited by prasad_N; 12th October 2015 at 15:11. Reason: spell mistake
    Thanks :-)

Similar Threads

  1. QResizeEvent called 3 times
    By mvbhavsar in forum Newbie
    Replies: 5
    Last Post: 17th December 2014, 16:06
  2. Replies: 8
    Last Post: 11th February 2014, 10:01
  3. Qt bug? Signal emitted once, slot called multiple times
    By MattPhillips in forum Qt Programming
    Replies: 22
    Last Post: 1st December 2010, 22:32
  4. filterAcceptRows() is being called many times for same souceRow.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2009, 03:49
  5. Replies: 0
    Last Post: 17th May 2008, 18:06

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.