Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a (not all) tree item always expanded in a QTreeView?

How can I make a (not all) tree item always expanded in a QTreeView? I cannot find a good way to do it.

like image 865
user1899020 Avatar asked Jan 30 '26 23:01

user1899020


2 Answers

You just need to set the itemsExpandable property to false by calling setItemsExpandable(false). This property holds whether the user can expand and collapse items interactively. Once the property is set to false, any items expanded by you will not be possible to collapse by the user.

like image 95
Daniel Hedberg Avatar answered Feb 01 '26 13:02

Daniel Hedberg


You can try:

tree_item.setExpanded(true)
tree_item.setDisabled(true)

I have not tested it but according to the docs it should work.

http://qt-project.org/doc/qt-4.8/qtreewidgetitem.html#setDisabled

like image 21
user937284 Avatar answered Feb 01 '26 12:02

user937284



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!