Results 1 to 2 of 2

Thread: tow column subitem in QTreeview

  1. #1
    Join Date
    Nov 2014
    Location
    Varese (Italy)
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Android

    Post tow column subitem in QTreeview

    Hello everyones,
    My idea is to realize a tree organized in tihs way:
    |
    item1
    |----->sub-item1------>sub-item2
    |
    |
    item2
    |----->sub-item1------>sub-item2
    |

    now I have realized this:

    model= new QStandardItemModel(nList.count(), 0);

    model->setHorizontalHeaderItem(0, new QStandardItem("Devices"));

    //devices
    for(int i=0; i < nListCell.count();i++){

    e = nList.at(i).toElement();

    QStandardItem *item = new QStandardItem(e.attribute(XML_ATTR_ID));

    item->appendRow(new QStandardItem(e.attribute(XML_ATTR_1)));
    item->appendRow(new QStandardItem(e.attribute(XML_ATTR_2)));

    model->setItem(i, 0, item);

    but this show that tree
    |
    |
    |
    item1
    ----->sub-item1
    ----->sub-item2

    I have not found anything realize my idea, and I'm not sure is possible to realize.
    can everyone help me ?

    thank you

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

    Default Re: tow column subitem in QTreeview

    There is an appendRow() overload that takes a list of items, one for each column.

    Cheers,
    _

Similar Threads

  1. QTreeView and Column/Row Gridlines
    By smhall316 in forum Newbie
    Replies: 1
    Last Post: 12th July 2013, 04:57
  2. QTreeview last Column visibility
    By kiran p in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2011, 10:25
  3. How to add subitem in treewidget
    By phillip_Qt in forum Qt Programming
    Replies: 11
    Last Post: 16th November 2009, 11:22
  4. Fixed Column in QTreeview
    By ormonde in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 07:49
  5. No delegate for 1 column in QTreeView
    By mace in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2007, 10:55

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.