Results 1 to 7 of 7

Thread: MVC - canFetchMore() is not working as expected

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

    Default MVC - canFetchMore() is not working as expected

    I have implemented customized model for lazily loading data, so I have reimplemented canfetchMore() & fetchMore().

    - they are working fine for root item, when i scroll down these functions are getting called and I am loading data & population it.
    - But in case of child's its not working as expected (may be my understanding is wrong). I have many rows (more than million) child's for the top level items, so I decided to load them also on demand or lazily. but canFetchMore() is calling only one time when I expand the item (when I expand the item i am reading top 100 immediate child's and inserting them, so that entire view is full with these child's & then when I scroll down my expectation is canFetchMore() should be called with parent as that child to which i inserted 100 child's but once i insert 100/some items into that item canFetchMore() is not calling until I collapse & expand it again.)
    because of this I am not able to fetch more/remaining child's & insert them.

    In one line: canfetchMore() is calling only when expand the item, Its not getting called when I expand & insert few items and then scroll down.

    Is this bug ? or Can i manage this in some other way. ???
    Thanks :-)

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

    Default Re: MVC - canFetchMore() is not working as expected

    It's a bug that ended up being a feature. It is theoretically possible to use the model the way you want (which seems reasonable) but Qt's QTreeView implementation does not offer such functionality.
    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.


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

    Default Re: MVC - canFetchMore() is not working as expected

    Quote Originally Posted by prasad_N View Post
    It's a bug that ended up being a feature..
    Strange feature, did somebody report this bug already ? (or can i report this as bug ?).

    Quote Originally Posted by prasad_N View Post
    It is theoretically possible to use the model the way you want
    Could you please let me know one way (more if possible :-) ) to handle this situation.
    Last edited by prasad_N; 9th October 2015 at 07:16.
    Thanks :-)

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

    Default Re: MVC - canFetchMore() is not working as expected

    I tried to get the last element with the help of view geometry while scrolling, But It did not work at all.

    Qt Code:
    1. scroolingDown(int val)
    2. {
    3. QModelIndex index = itemAt(rect().bottomLeft());
    4. }
    To copy to clipboard, switch view to plain text mode 


    any other suggestions/way to achieve this ??
    Thanks :-)

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

    Default Re: MVC - canFetchMore() is not working as expected

    Any help or suggestions from Qt experts please ??
    Thanks :-)

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

    Default Re: MVC - canFetchMore() is not working as expected

    I did in the way I am not supposed to do.

    in data() function I am checking If it is last child Of a valid parent item(non root item) & This parent still have some items than I am fetching some more data and inserting.

    I know this is the stupid way as I am fetching & inserting data in data() function & I should not do it here, But did this at this point of of time nothing flashes in my mind.
    May be I need to go through QTreeView source code to get some pointers to work on this feature.
    Thanks :-)

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

    Default Re: MVC - canFetchMore() is not working as expected

    Quote Originally Posted by prasad_N View Post
    Strange feature, did somebody report this bug already ? (or can i report this as bug ?).
    Feel free to do that.

    Could you please let me know one way (more if possible :-) ) to handle this situation.
    You would have to reimplement the view to do it properly. You have to detect a situation where the view is scrolled to a point where the last populated item is visible on a certain level and then ask the model to update itself.
    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.


Similar Threads

  1. QAction::setEnabled() Not Working as Expected
    By pmwalk in forum Qt Programming
    Replies: 6
    Last Post: 24th March 2012, 06:20
  2. QDir not working as expected
    By BettaUseYoNikes in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2011, 16:55
  3. Replies: 2
    Last Post: 22nd December 2010, 10:37
  4. Replies: 0
    Last Post: 17th August 2010, 14:37
  5. QTableView not working as expected.
    By junxuan in forum Qt Programming
    Replies: 7
    Last Post: 30th July 2009, 08:17

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.