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. QSortFilterProxyModel got index out of range error when setting header data
Qt 6.11 is out! See what's new in the release blog

QSortFilterProxyModel got index out of range error when setting header data

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.5k 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.
  • J Offline
    J Offline
    justDance
    wrote on last edited by
    #1

    I call setSourceModel() at widget constructor, at this point header data in source model as a QStringList is empty. Later when I call setHeaderData() to set header data based on the info I got from network, I get error message saying that QVector index out of range. it's from QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged().
    Anybody knows why? All qt examples online doesn't cover this case.

    Thanks,

    1 Reply Last reply
    0
    • J Offline
      J Offline
      justDance
      wrote on last edited by
      #2

      more info about my problem: in my setHeaderData() function, I have "emit headerDataChanged(Qt::Horizontal, section, section);", this signal triggered slot QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged().

      But based on QAbstractItemModel Class Reference, "When reimplementing function setHeaderData(), the headerDataChanged() signal must be emitted explicitly." so seems there is nothing wrong with my code.

      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