Dummy Delegate creation issue - ListView & Model
-
Dummy delegates are created with out any data.
Problem :
I have 300 elements in the model. As I keep scrolling list view, delegates are getting created. Now ListView is displaying the 16th element.Now remove 18-300 elements in the model like the follows.
beginRemoveRows(QModelIndex(),18,300); endRemoveRows();
Now I keep scrolling list view.
Now I see some 5-6 dummy delegates after 18 like 18,19,20,21. However there is no data filled in delegate. It is empty box. I can see Component.onCompleted(..) message for this dummy delegates.
Model is publishing the row count as 17 only.
List view is not calling data(..) method for 18,19,20,21 like that.
But I see the dummy delegates without data.This is issue is happening only with specific example. It always happens with my example.
I tried to reproduce the issue with another example using ListView. Not able to see this.Any inputs on why these dummy delegates are getting created ?
Any inputs to troubleshoot ? -
I am able to solve this issue. I used timer to remove the elements again. Inside the timer slots calling the remove rows by calling beginRemoveRows(..). I have no explanation how this works.
But this worked and dummy rows are not visible.First Time - beginRemoveRows(QModelIndex(),m_start,m_end); this->m_timer.start(); endRemoveRows(); Inside the timer slots - void MyModel::timerSlot(){ beginRemoveRows(QModelIndex(),m_start,m_end); endRemoveRows(); this->m_timer.stop();
}
-
That's very weird! Thanks for sharing the solution!
-
@sierdzio yes, it is very weird. I struggled to get the solution & explanation. However not successful. It is software & it worked!!!. Moving on now..