Results 1 to 5 of 5

Thread: Need to remove root node from QTreeView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2014
    Posts
    7
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Need to remove root node from QTreeView

    Thank you for the replay!

    I tried using these 2 functions but I don't get the desired result! The problem with setRootIndex is that if I use it like this:
    QModelIndex parentIndex = myModel->index(0,0);
    QModelIndex newIndex = myModel->index(0,0, parentIndex);
    myTree->setRootIndex(newIndex);

    I actually get the childs of AA ! not even the AA-parent is shown!!!

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

    Default Re: Need to remove root node from QTreeView

    Looks like you are going down one level too much.
    Initially the root index is QModelIndex(), you want index(0, 0), but you are setting index(0, 0, index(0, 0)

    Cheers,
    _

  3. #3
    Join Date
    Apr 2014
    Posts
    7
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Need to remove root node from QTreeView

    THANK YOU!!!!!
    You were right: myTree->setRootIndex( myModel->index(0,0));
    did the trick and now I have the desired structure in my view:
    AA
    BB
    CC

Similar Threads

  1. QTreeWidget set invisible root node?
    By Braf in forum Qt Programming
    Replies: 2
    Last Post: 10th February 2013, 03:03
  2. Remove node in XML file
    By pinjul in forum Newbie
    Replies: 11
    Last Post: 7th February 2013, 11:14
  3. How to create root node inQDirModel
    By deepak in forum Qt Programming
    Replies: 1
    Last Post: 29th August 2012, 08:03
  4. customize the root node of a treeview
    By billconan in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2009, 09:06
  5. remove node in xml file
    By mattia in forum Newbie
    Replies: 1
    Last Post: 6th March 2008, 14:25

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.