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. Subclassed QSortFilterProxyModel doesn't forward dataChanged signal
Forum Updated to NodeBB v4.3 + New Features

Subclassed QSortFilterProxyModel doesn't forward dataChanged signal

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

    Hi,
    I've got my (QAbstractTableModel) model that occasionally emits the dataChanged signal. Then I've got a (QTableView) view which has a reimplemented dataChanged slot containing
    @qDebug() << "Yay!";@

    If I directly set the model to the view, "Yay!" is printed as expected, so that seems to work fine.

    Between model and view, I actually place a QSortFilterProxyModel subclass. The only thing this subclass reimplements is:
    @::headerData(int section, Qt::Orientation orientation, int role) const
    ::columnCount(const QModelIndex &parent) const
    ::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const@

    And these three (apart from being very simple) seem to work fine, since column removing/adding/sorting etc. works as expected.

    But "Yay!" never happens.
    I've checked the QSortFilterProxyModel source code and it seems to me, the dataChanged is handled, at least they connect it to "_q_sourceDataChanged" which does some fancy source-proxy-mapping.

    Any hints what I'm doing wrong would be nice.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      Ha!
      It's always the things that "are correct for sure" that bite you!
      Turns out just printing "Yey!" wasn't so smart, the parameters I passed to dataChanged were wrong and so the filter proxy didn't let the signal through.

      I emitted like this:
      @emit dataChanged(index(id, 0), index(id, columnCount()));@
      When I should have emitted
      @emit dataChanged(index(id, 0), index(id, columnCount()-1));@
      Obviously ;)
      Sadly this "column out of bounds" situation doesn't produce any qDebug output in the model or view, but is silently turned into column id -1 and row id 0 (!). Sneaky.

      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