Originally Posted by
wysota
So what does itemAt() return if it "isn't able to find the element"?
When I scroll down IndexAt() (very sorry It is IndexAt() not ItemAt()) is returning some items randomly (As I scroll down All the items should come into view from down & I thought IndexAt() can recognize all the items, But as I said it is skipping some items & its is happening randomly, there is no particular pattern even).
Originally Posted by
wysota
If itemAt() returns top-level index with row = 2 and previously you fetched items with parent set to row = 1 then based on that you can deduce you should fetch those missing items from first top-level row.
I just attached a result to make clear what is the exact problem. tree.PNG
- In attachement, 20 is child of my 1st top level Item but this has more siblings down which I did not load initially.
- Now when I scroll down I wanted to find this items (which has data as 20) & find out if its more siblings & add them
For that I did some thing like this
if(l_vScroll)
{
connect(l_vScroll, SIGNAL(valueChanged(int)), this, SLOT(verticallScrollBarMoved(int)), Qt::DirectConnection);
}
void TreeView::verticallScrollBarMoved(int f_val)
{
QModelIndex index
= this
->indexAt
(this
->viewport
()->rect
().
bottomLeft());
//Now my assumption is as I scroll down in this function index of last child (which has data 20) should get caught (correct me If i am wrong) & with this index I can add more siblings to it
//But here I am not able to get all the indexes which are coming from down when I am scrolling
}
QScrollBar* l_vScroll = verticalScrollBar();
if(l_vScroll)
{
connect(l_vScroll, SIGNAL(valueChanged(int)), this, SLOT(verticallScrollBarMoved(int)), Qt::DirectConnection);
}
void TreeView::verticallScrollBarMoved(int f_val)
{
QModelIndex index = this->indexAt(this->viewport()->rect().bottomLeft());
//Now my assumption is as I scroll down in this function index of last child (which has data 20) should get caught (correct me If i am wrong) & with this index I can add more siblings to it
//But here I am not able to get all the indexes which are coming from down when I am scrolling
}
To copy to clipboard, switch view to plain text mode
Bookmarks