Results 1 to 16 of 16

Thread: Always show QTreeview branches in the far left column

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Location
    Copenhagen
    Posts
    50
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Always show QTreeview branches in the far left column

    I'm working with a Qtreeview and I'm facing some problems having the treview shown when either the first column is hidden or when I rearrange the tree.

    I'm using a custom model where I've tried to put in a 'branch column' (m_branchcolumn see below) to map the parent to the first visible column in the treeview but it doesn't work. I always see the treeview nodes (the plus and minus signs) in column zero. I'm using an internal record representation like the nodeitem from the simple treeview example shipped with Qt.

    Qt Code:
    1. QModelIndex ViewModel::parent(const QModelIndex &child) const
    2. {
    3. if (!child.isValid())
    4. return QModelIndex();
    5.  
    6. Record *rec = recordFromIndex(child);
    7. if (!rec)
    8. return QModelIndex();
    9.  
    10. Record *parentRecord = rec->parent;
    11. if (!parentRecord)
    12. return QModelIndex();
    13.  
    14. if(parentRecord == rootRecord)
    15. return QModelIndex();
    16.  
    17. Record *grandparentRecord = parentRecord->parent;
    18.  
    19. if (!grandparentRecord)
    20. return QModelIndex();
    21.  
    22. int row = grandparentRecord->children.indexOf(parentRecord);
    23. return createIndex(row, m_branchcolumn, parentRecord);
    24. }
    To copy to clipboard, switch view to plain text mode 

    How can I make sure always to show the tree branches in the far left visible column even after column change and with hidden columns?
    Attached Images Attached Images

Similar Threads

  1. QTreeView/QHeaderView : resize handle on the left
    By Jeremy in forum Qt Programming
    Replies: 3
    Last Post: 14th May 2009, 22:43
  2. Replies: 1
    Last Post: 23rd November 2008, 14:11
  3. Fixed Column in QTreeview
    By ormonde in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 07:49
  4. No delegate for 1 column in QTreeView
    By mace in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2007, 10:55
  5. Replies: 1
    Last Post: 12th November 2006, 16:56

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.