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. SortFilterProxyModel and modelData
Forum Updated to NodeBB v4.3 + New Features

SortFilterProxyModel and modelData

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 99 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.
  • A Offline
    A Offline
    Ashley Paul
    wrote last edited by
    #1

    How can I use StringSorter or RoleSorter with custom c++ models that are normally accessed by modelData?

    ListView {
      anchors.fill: parent
      model: SortFilterProxyModel {
        model: myCustomModel
    
        sorters: StringSorter {
          roleName: "name"
        }
      }
    
      delegate: Text {
        required property var modelData
        text: modelData.name
      }
    }
    
    GrecKoG 1 Reply Last reply
    0
    • A Ashley Paul

      How can I use StringSorter or RoleSorter with custom c++ models that are normally accessed by modelData?

      ListView {
        anchors.fill: parent
        model: SortFilterProxyModel {
          model: myCustomModel
      
          sorters: StringSorter {
            roleName: "name"
          }
        }
      
        delegate: Text {
          required property var modelData
          text: modelData.name
        }
      }
      
      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote last edited by
      #2

      @Ashley-Paul You can't, those work based on roles.

      If your model is a list of QObject* I would suggest using https://github.com/OlivierLDff/ObjectListModel/ or QRangeModel as your model.

      1 Reply Last reply
      1
      • A Ashley Paul has marked this topic as solved

      • Login

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