Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dummy Delegate creation issue - ListView & Model
QtWS25 Last Chance

Dummy Delegate creation issue - ListView & Model

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 243 Views
  • 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.
  • D Offline
    D Offline
    dheerendra
    Qt Champions 2022
    wrote on 9 Sept 2020, 09:45 last edited by
    #1

    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
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 10 Sept 2020, 08:01 last edited by dheerendra 9 Oct 2020, 08:04
      #2

      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
      2
      • S Offline
        S Offline
        sierdzio
        Moderators
        wrote on 10 Sept 2020, 08:05 last edited by
        #3

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

        (Z(:^

        1 Reply Last reply
        2
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 10 Sept 2020, 08:06 last edited by
          #4

          @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
          1

          3/4

          10 Sept 2020, 08:05

          • Login

          • Login or register to search.
          3 out of 4
          • First post
            3/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved