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. ???
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.
Re: MVC - canFetchMore() is not working as expected
Quote:
Originally Posted by
prasad_N
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
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.
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.
Code:
scroolingDown(int val)
{
}
any other suggestions/way to achieve this ??
Re: MVC - canFetchMore() is not working as expected
Any help or suggestions from Qt experts please ??
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.
Re: MVC - canFetchMore() is not working as expected
Quote:
Originally Posted by
prasad_N
Strange feature, did somebody report this bug already ? (or can i report this as bug ?).
Feel free to do that.
Quote:
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.