Results 1 to 5 of 5

Thread: How to merge/append a portion of QStandardItemModel list to an existing list item;

  1. #1
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Smile How to merge/append a portion of QStandardItemModel list to an existing list item;

    hello everyone
    i made a model and treeview list according to the model/view tutorial, suppose the list structure is as following(each indent indicates a child level):

    item1
    a
    item2
    b
    c
    d

    how can i take item2 as a pointer or whatever and append it item1 as a child, and still the item2 retains all its childrens, so I want to do this:

    item1
    a
    item2
    b
    c
    d

    is there a way to do this? thank you.

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

    Default Re: How to merge/append a portion of QStandardItemModel list to an existing list item

    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
    Jun 2012
    Posts
    4
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to merge/append a portion of QStandardItemModel list to an existing list item

    hi wysota
    takeItem() returns a QStandardItem, does it retain all the children? also insertRow() needs a QList<QStandardItem*> as the second argument. how do I fit the Item in there?

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

    Default Re: How to merge/append a portion of QStandardItemModel list to an existing list item

    Quote Originally Posted by startyourengine View Post
    takeItem() returns a QStandardItem, does it retain all the children?
    Why don't you just try and see for yourself?

    also insertRow() needs a QList<QStandardItem*> as the second argument. how do I fit the Item in there?
    There are three variants of this method.
    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.


  5. The following user says thank you to wysota for this useful post:

    startyourengine (14th June 2012)

  6. #5
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to merge/append a portion of QStandardItemModel list to an existing list item

    ah, it worked. Thanks a bunch!

Similar Threads

  1. Replies: 7
    Last Post: 15th May 2014, 19:29
  2. Replies: 1
    Last Post: 23rd April 2011, 17:33
  3. List View with sections for alphabetialy sorted list
    By woodtluk in forum Qt Programming
    Replies: 4
    Last Post: 12th October 2010, 11:50
  4. style a list item
    By savar in forum Newbie
    Replies: 3
    Last Post: 18th March 2010, 18:21
  5. deleting first item in a list
    By soul_rebel in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2006, 17:49

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.