8
votes

Does anyone know if it's possible the flatten a QTreeView/QTreeWidget while still being able to expand child items.

What the default is:

- A
  -> A1
  -> A2
- B
  -> B2
+ C

- is expanded and + is collapsed

What I would like:

- A
  A1
  A2
- B
  B2
+ C

all collapsed

+ A
+ B
+ C

A, B, C are the root items.

1
Can you get it from styling the QTreeView's items? Here is an example that styles things like color, but not much to see on actually positioning the items. You can use selectors to get the QTreeView's nodes and children, so you may be able to use the QSS to position the sub items. This is only a suggestion, though. Hence it being a comment and not an answer. - Eli Hooten
If I could just style it that would be the easiest. I haven't tried. - Nathan W
hmmm never used to be like that, used to just be given to the accepted answer. All good. - Nathan W

1 Answers

7
votes
MyTree -> setIndentation (0) ;