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. How to reset order of QAbstractListModel
Forum Updated to NodeBB v4.3 + New Features

How to reset order of QAbstractListModel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 459 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.
  • P Offline
    P Offline
    PhiBh
    wrote on last edited by
    #1

    Hi every one,
    I want to reset order of QAbstractListModel from old qlist,
    I can use beginMoveRows() endMoveRows(), in the loop for the list, but Is there a better way?
    I don't want clear the list. Thanks!

    JonBJ 1 Reply Last reply
    0
    • P PhiBh

      Hi every one,
      I want to reset order of QAbstractListModel from old qlist,
      I can use beginMoveRows() endMoveRows(), in the loop for the list, but Is there a better way?
      I don't want clear the list. Thanks!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @PhiBh
      Depends what you mean by "a better way" :)

      I know nothing about QML, but this seems to be a straight Qt model/view question. You can use begin/endMove Rows(). But I would do that if you are moving, say, 1 row around. It can get difficult to calculate if you are, say, sorting the entire list, or don't want to calculate which of many rows have been moved where. Then it is simpler to just call QAbstractItemModel::beginResetModel(), do your complete changes, and endResetModel(). Note that you should then read the referenced documentation, telling you that all views and e.g. flags() are reset. You would want to test this to see what effect it has on your existing views and how they refresh in response.

      1 Reply Last reply
      2

      • Login

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