Results 1 to 3 of 3

Thread: QStandardItemModel's insertRow() did't make a grandchild item in QTreeView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QStandardItemModel's insertRow() did't make a grandchild item in QTreeView

    You need to insert a column as well. The insertRow which takes a QStandardItem does this automatically.
    Qt Code:
    1. if (childItemIndex.isValid()) {
    2. isSuccess = model.insertRow(0, childItemIndex); // make a grandchild, but the item does not appear
    3. isSuccess = model.insertColumn(0, childItemIndex); // Need this...
    4. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to numbat for this useful post:

    kichi (17th January 2010)

  3. #2
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStandardItemModel's insertRow() did't make a grandchild item in QTreeView

    Quote Originally Posted by numbat View Post
    You need to insert a column as well. The insertRow which takes a QStandardItem does this automatically.
    Qt Code:
    1. if (childItemIndex.isValid()) {
    2. isSuccess = model.insertRow(0, childItemIndex); // make a grandchild, but the item does not appear
    3. isSuccess = model.insertColumn(0, childItemIndex); // Need this...
    4. }
    To copy to clipboard, switch view to plain text mode 
    Your advice has solved the problem.
    Thank you very much.
    kichi

Similar Threads

  1. QTreeView::item stylesheet
    By Baasie in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2009, 14:55
  2. QTreeView and item editing
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 18:56
  3. QStandardItemModel insertRow crashing
    By munna in forum Qt Programming
    Replies: 1
    Last Post: 27th June 2008, 11:55
  4. QTableView QTablemodel & insertRow
    By pfusterschmied in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2007, 12:43
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24

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