Search code examples
c++qtqtguiqtreewidgetqtreewidgetitem

set subchild not to indent in qtreewidget when I expand them


I have a QTreeWidget and I want children of a QTreeWidgetItem not indent when I expand them. I want to set the line only for top items. The first screenshot demonstrates what I would like to have, and the second what I am currently having. Would you please help me with how to change it to be like the first one? Thank you in advance!

first picture

second picture![][1]


Solution

  • This is not possible by QTreeWidget since you can only set the indentation globally. You would need to create your own class implementing this logic, e.g. QListWidgets connected to each other, or just a brand new tree widget implementation. You could also of course improve the existing QTreeWidget and send a patch.