Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Dummy Delegate creation issue - ListView & Model

    QML and Qt Quick
    2
    4
    92
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dheerendra
      dheerendra Qt Champions 2022 last edited by

      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 ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by dheerendra

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

        }

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply Reply Quote 2
        • sierdzio
          sierdzio Moderators last edited by

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

          (Z(:^

          1 Reply Last reply Reply Quote 2
          • dheerendra
            dheerendra Qt Champions 2022 last edited by

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

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply Reply Quote 1
            • First post
              Last post