Results 1 to 2 of 2

Thread: how to use QTreeView::setFirstColumnSpanned to span a child item

Threaded View

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

    Talking how to use QTreeView::setFirstColumnSpanned to span a child item

    hello

    i have a treeview in the following structure:

    parent1
    child10
    child11
    parent2
    child20
    child21
    parent3

    the following code works and it spanned all the parents that has a child, so in this case parent1 and parent2 get spanned, parent3 doesn't.
    Qt Code:
    1. QModelIndex idx = model->invisibleRootItem()->index();
    2. for (int i=0; i<model->rowCount(); i++){
    3. if (model->item(i,0)->hasChildren()){
    4. Treeview->setFirstColumnSpanned(i, idx, true);
    5. }
    6. }
    To copy to clipboard, switch view to plain text mode 

    but what I'm actually trying to do is to get the children's first column spanned, so I thought (const QModelIndex & parent) the second parameter of setFirstColumnSpanned takes the parent index of the item that I want to span. so I replace
    Qt Code:
    1. Treeview->setFirstColumnSpanned(i, idx, true)
    To copy to clipboard, switch view to plain text mode 
    with
    Qt Code:
    1. Treeview->setFirstColumnSpanned(i, model->Item(i,0)->index(), true)
    To copy to clipboard, switch view to plain text mode 
    but it doesn't work.

    can somebody point me to the right direction? or is this doable? thank you.
    Last edited by startyourengine; 15th August 2012 at 17:21.

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


Similar Threads

  1. QTreeView and d&d
    By FuturePrimitive in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2011, 20:27
  2. QTreeView
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2009, 19:51
  3. use QTreeView
    By totosugito in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2008, 09:33
  4. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 21:22
  5. QTreeView
    By merry in forum Qt Programming
    Replies: 5
    Last Post: 29th May 2007, 08:38

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.