Results 1 to 3 of 3

Thread: How to set parent of a QTreeWidgetItem

  1. #1
    Join Date
    Jul 2012
    Posts
    53
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to set parent of a QTreeWidgetItem

    Hi,

    I'm using QTreeWidget to implement a tree like

    root
    / \
    a b
    | /\
    d e f

    I want to reset the parent of "e" to "a", like e->setParent(a);
    But I cannot find any function in QTreeWidgetItem to change the parent.
    I 'm not using drag and drop. Is there a way to do it without using model and view?
    Thanks in advance.

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

    Default Re: How to set parent of a QTreeWidgetItem

    Call addChild() on the new parent item passing the "e" item as the argument.
    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. The following user says thank you to wysota for this useful post:

    Seishin (7th December 2012)

  4. #3
    Join Date
    Jul 2012
    Posts
    53
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set parent of a QTreeWidgetItem

    Thanks for the quick reply. I was focus on searching "changing parent" and missed "child".

Similar Threads

  1. Replies: 11
    Last Post: 3rd March 2012, 22:21
  2. qtreewidgetitem
    By ahmetturan in forum Newbie
    Replies: 1
    Last Post: 24th July 2011, 19:38
  3. Replies: 5
    Last Post: 23rd September 2010, 13:58
  4. Replies: 5
    Last Post: 21st April 2010, 21:36
  5. QTreeWidgetItem
    By Sarma in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2006, 19:52

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.