Results 1 to 4 of 4

Thread: QTreeView and RootIndex

  1. #1
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QTreeView and RootIndex

    Hi guys,
    i have a problem. I use a QTreeView and with a subclass of QAbstractItemModel.
    It works.
    A
    ..B
    ..C
    ....D
    For filter reasons I change the root index via setRootIndex.
    Qt Code:
    1. setRootIndex(B);
    To copy to clipboard, switch view to plain text mode 

    It works, but after setting the root index, the rootIndex is not shown. (rootIsDecorated is true.)
    C
    ....D

    Furthermore I'm not able to unset the filter, because my A node never gets back.
    Qt Code:
    1. setRootIndex(A); // A is model.index(0,0);
    To copy to clipboard, switch view to plain text mode 

    What can I do?
    thanks

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

    Default Re: QTreeView and RootIndex

    Root index is never shown. The view always shows children of the root index.
    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
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeView and RootIndex

    Thank you wysota!
    If I don't set the rootIndex initially, the root index is shown.

    greets

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

    Default Re: QTreeView and RootIndex

    Because it is set to an invalid index (QModelIndex()) which happens to point to the top of the 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.


Similar Threads

  1. QTreeView and d&d
    By FuturePrimitive in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2011, 20:27
  2. QTreeView
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2009, 19:51
  3. QTreeView. Qt.4.4.1
    By janEUcitzen in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2008, 08:53
  4. Replies: 1
    Last Post: 2nd July 2008, 19:45
  5. use QTreeView
    By totosugito in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2008, 09:33

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.