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. QML ListView is not updated for removal
Qt 6.11 is out! See what's new in the release blog

QML ListView is not updated for removal

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.9k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    tuanster
    wrote on last edited by
    #1

    I have a custom model that is derived from QAbstractListModel and it has a variable (_sqlTableModel) holding an instance of QSqlTableModel. The code is as follows:

    @
    beginResetModel();
    _sqlTableModel->removeRows(index, 1);
    endResetModel();
    @

    The problem that I am seeing is that the view doesn't get refreshed and it still displays the deleted item even though the item is actually removed from the model. This doesn't make sense. Any advice to correct this issue?

    I have similar code with append, insert, and move and everything works fine.

    Thanks for any tip.

    [EDIT: code formatting, Volker]

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ixSci
      wrote on last edited by
      #2

      For removing rows you should use beginRemoveRows()\endRemoveRows()

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tuanster
        wrote on last edited by
        #3

        Thanks! That works.

        1 Reply Last reply
        0

        • Login

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