Results 1 to 11 of 11

Thread: QTreeView + QAbstractItemModel + QSortFilterProxyModel = insertRows fails

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Location
    Moscow
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTreeView + QAbstractItemModel + QSortFilterProxyModel = insertRows fails

    Quote Originally Posted by wysota View Post
    What if you check if parent is a valid index before passing it to mapToSource?
    I will try, but don't see the point of it - parent is being defined just before insertRows() is called - you can see, how it is done, in comment #3.
    For me it looks fine, and debugger shows normal parent - when I breakpoint on "mProxyModel->insertRows(row, 1, parent)".

    Quote Originally Posted by wysota View Post
    What is the model of the index passed there, anyway?
    Sorry, I am not sure I understand fully what you mean.
    Could you explain? Or maybe the call in comment #3 will help? Getting parent and insertRows() call are shown there.
    It is taken from tree selection model - so, I think it is proxy model index. Am I wrong?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeView + QAbstractItemModel + QSortFilterProxyModel = insertRows fails

    Quote Originally Posted by KanareykaVBusikah View Post
    I will try, but don't see the point of it - parent is being defined just before insertRows() is called - you can see, how it is done, in comment #3.
    And it can be an empty model index...

    Sorry, I am not sure I understand fully what you mean.
    What is the object returned from QModelIndex::model() for that index. Is it the proxy model instance or some other model.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2013
    Location
    Moscow
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTreeView + QAbstractItemModel + QSortFilterProxyModel = insertRows fails

    Quote Originally Posted by wysota View Post
    And it can be an empty model index...
    It is not empty definitely, this I did have checked (debuger shows row index there and correct object data and so on).

    Quote Originally Posted by wysota View Post
    What is the object returned from QModelIndex::model() for that index. Is it the proxy model instance or some other model.
    Oh, thanks really! I did not grasp, I could check the model
    Will try.

  4. #4
    Join Date
    Sep 2013
    Location
    Moscow
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTreeView + QAbstractItemModel + QSortFilterProxyModel = insertRows fails

    Hello again!
    Sorry for long absence - there just was some important and pressing issues to be done in my life.

    The idea of QModelIndex::model() helped me to understand some details, but I advanced only a little.
    Now I see something in gdb output, that I can not understand and explain - I expect different to see.
    I was sure I am experienced enough to understand, but no, what I see makes me completely desperate.

    I made a pair of screenshot, so I hope you can help me to explain what I see - and WHY I see it.
    These are screenshots of debugging insertRow.
    To run the function - I a) select an item in my tree and b) enter some text (pSubject variable). Then the function is called.

    qt1.jpg
    On this picture you see:
    - I stoped at "QModelIndex index = index from selection model"
    - Pressed "F10" to move to the next statement.
    Now I see the correct index variable: column = 0, row = 9, model = ExTreeProxy (that is proxy model).
    It is marked with red rectangles.
    So, it's everything ok on this sceen.

    Then come oddnesses:
    qt2.jpg

    Here you see
    1) mark "1" on the picture - shows what I get after statement "sourceIndex = map from index".
    As I selected index - I see it in the tree, I get it correctly from selection model - so, I expect to have correct sourceIndex.
    But I get invalid one.
    2) mark "2" on the picture - shows what I get when I go into "else" branch.
    There is an incorrect index (column=0, row=0). What is it? On what reason index changed?

    I thought this might be some errors in debugger - and I have build gdb from source.
    But this did not help. I see the same oddnesses again.

    Can you help in any way? Explain why I see this for the beginning...

Similar Threads

  1. Replies: 10
    Last Post: 22nd March 2019, 15:03
  2. QSortFilterProxyModel QAbstractItemModel
    By Qiieha in forum Qt Programming
    Replies: 2
    Last Post: 29th October 2012, 08:01
  3. QSortFilterProxyModel::insertRows always adds rows to the end
    By Agnostic Pope in forum Qt Programming
    Replies: 1
    Last Post: 7th May 2012, 23:23
  4. Replies: 2
    Last Post: 8th December 2010, 20:37
  5. Need help with QTreeView/QAbstractItemModel
    By Valheru in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2006, 15:09

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
  •  
Qt is a trademark of The Qt Company.