Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change QTreeView's expand/collapse column?
Forum Updated to NodeBB v4.3 + New Features

How to change QTreeView's expand/collapse column?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kainjow
    wrote on last edited by
    #1

    I am trying to figure out how to change the column of a QTreeView that contains the expanding and collapsing controls. Been looking at all the various types of roles and options in QTreeView, QAbstractItemModel, QItemDelegate, etc. Haven't seen anything that lets me change it, although I can move the columns so I know it's possible.

    I want the first column to be a single, fixed checkbox, and the second column to be the expanding +/- (triangle), icon, and name (and extra fixed columns after).

    Thanks.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AlekseyOk
      wrote on last edited by
      #2

      try to use http://doc-snapshot.qt-project.org/4.8/qabstractitemview.html#setIndexWidget

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kainjow
        wrote on last edited by
        #3

        I'm not sure how that method can help me.

        I ended up looking at the source code for QTreeView, and it appears that the logical column with the disclosure triangle is hard coded to 0. I am able to use moveSection() to swap the first and second columns, but on Windows it doesn't draw the highlight or mouseover effects properly, although I'm sure that can be changed with a stylesheet.

        However, for now I'm just going to put the checkbox into the disclosure column. Maybe later I'll separate it out again but this layout actually saves more space.

        Really all I want is an equivalent to NSOutlineView's setOutlineTableColumn method.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved