Results 1 to 2 of 2

Thread: QSortFilterProxyModel::insertRows always adds rows to the end

  1. #1
    Join Date
    Dec 2011
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSortFilterProxyModel::insertRows always adds rows to the end

    So I've got a QSortFilterProxyModel with a QAbstractTableModel underneath.

    Before I sort the table, inserting rows works fine. If I put a row in at 3, for example, 3 moves to 4, etc.

    Once I sort the table however, inserting a row always goes at the end of the beginning and this behavior appears random. Is there a good way of doing this? Here's what I've tried:

    * Using mapToSource. Unfortunately, since the index doesn't exist yet, this doesn't work.
    * The default method, QSortFilterProxyModel::insertRows. This fails as described above.

    I've tried looking at Qt's source code as well and it appears that I'd need to basically create a mapping inside the proxy model for the correct index before creation, but I'm not quite sure how to do that using the public API. I'll keep looking, but if anyone can help me out here, I'd appreciate it

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSortFilterProxyModel::insertRows always adds rows to the end

    Are you falling foul of this? From the docs:
    Note: By default, the model does not dynamically re-sort and re-filter data whenever the original model changes. This behavior can be changed by setting the dynamicSortFilter property.
    Perhaps you could post a small, self-contained program that demonstrates the problem.

Similar Threads

  1. [ANN] ODB C++ ORM adds support for Qt
    By borisk in forum Qt Programming
    Replies: 0
    Last Post: 28th April 2011, 12:08
  2. Rowcount and insertrows differences
    By tonnot in forum Qt Programming
    Replies: 2
    Last Post: 14th April 2011, 08:56
  3. PyQT QwtScaleDiv adds ticks to axis
    By mbernasocchi in forum Qwt
    Replies: 12
    Last Post: 13th April 2011, 11:29
  4. Replies: 0
    Last Post: 13th April 2011, 08:47
  5. QTable insertRows issue
    By PrimeCP in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2007, 09:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.