Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Dummy Delegate creation issue - ListView & Model


  • Qt Champions 2017

    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 ?


  • Qt Champions 2017

    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();
    

    }


  • Moderators

    That's very weird! Thanks for sharing the solution!


  • Qt Champions 2017

    @sierdzio yes, it is very weird. I struggled to get the solution & explanation. However not successful. It is software & it worked!!!. Moving on now..


Log in to reply