Results 1 to 9 of 9

Thread: Problem with ProxyModel merging models with QSortFilterProxyModel.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2014
    Location
    Germany
    Posts
    14
    Thanks
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with ProxyModel merging models with QSortFilterProxyModel.

    Hmmm, that's correct. But this changes nothing. It's still does not work.
    If I understand it correctly, I have to do the mapping in both slots, but interestingly it works without this mapping the the rowsAboutToBeInserted() slot. I tried to remove the mapping from rowsAboutToBeRemoved() temporarily, but no change again.

    Because I think it is correct to map it in both functions, I added the missing mapping to rowsAboutToBeInserted() too.

    Now my rowsAboutToBeInsertedSlot() slot looks like:

    Qt Code:
    1. void MergeProxyModel::rowsAboutToBeInsertedSlot(const QModelIndex &parent, int first, int last)
    2. {
    3. QAbstractTableModel *smodel = qobject_cast<QAbstractTableModel *>(sender());
    4. const int offset = getOffset(smodel);
    5. beginInsertRows(parent, first + offset, last + offset);
    6. }
    To copy to clipboard, switch view to plain text mode 

    Would a small example application to test it, help?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with ProxyModel merging models with QSortFilterProxyModel.

    Quote Originally Posted by SvenA View Post
    Would a small example application to test it, help?
    Can't hurt. I don't have time today unfortunately, but someone else might.
    A small test application often also leads to discovering the bug yourself

    Cheers,
    _

  3. #3
    Join Date
    Jul 2014
    Location
    Germany
    Posts
    14
    Thanks
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with ProxyModel merging models with QSortFilterProxyModel.

    Thanks for your help!
    I found the bug.

    The model itself was right. The bug was in the source model which was used by my proxy model.
    In the beginRemoveRows() call I had an offset by one. Was hard to find.

    Nevertheless, thanks for your time and input!

    Cheers!

  4. #4
    Join Date
    Apr 2010
    Posts
    15
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with ProxyModel merging models with QSortFilterProxyModel.

    Could you please share the final version of MergeProxyModel class?

  5. #5
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Problem with ProxyModel merging models with QSortFilterProxyModel.

    Quote Originally Posted by anda_skoa View Post
    A small test application often also leads to discovering the bug yourself
    Dang @anda_skoa, you're good!
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

Similar Threads

  1. TableView ProxyModel problem
    By poporacer in forum Newbie
    Replies: 11
    Last Post: 23rd August 2011, 04:08
  2. Custom ProxyModel or Two Sync'd Models ?
    By SSurgnier in forum Qt Programming
    Replies: 2
    Last Post: 2nd August 2011, 18:44
  3. Replies: 9
    Last Post: 11th April 2011, 10:05
  4. ProxyModel problem
    By waynew in forum Qt Programming
    Replies: 1
    Last Post: 14th February 2010, 06:40
  5. QSortFilterProxyModel with multiple source models
    By hoshy in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2009, 20:59

Tags for this Thread

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.