Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Custom QAbstractItemModel & persistentIndexList
Forum Updated to NodeBB v4.3 + New Features

Custom QAbstractItemModel & persistentIndexList

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 312 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by
    #1

    HI

    I have custom QAbstractListModel called MTModel.
    It has 20 rows of data.
    Implemented the following functions in model

    int rowCount(const QModelIndex &parent = QModelIndex()) const;
     int columnCount(const QModelIndex &parent = QModelIndex()) const;
     QVariant  data(const QModelIndex &index, int role = Qt::DisplayRole) const ;
     QHash<int, QByteArray> roleNames() const;
    

    When I call

    QModelIndexList pIndexList = this->persistentIndexList();
    

    It always return 0(zero)

    Any idea why it returns zero ? I was expecting this as 20.
    Any thing missing here ?

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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you create any such indexes ?
      If not then that's normal that the list is empty.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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