Sophus
Sophus

Reputation: 491

PyQt: How to expand all children in a QTreeWidget

There is no real problem, I have just a cosmetic problem. Well, first I create a form with Qt Designer. On this form I place a QTreeWidget. We are still in Qt Designer. In QTreeWidget, I make a few entries (parents), and then I also take a few child entries. When I am done, I save the ui-file and then I load this file - using loadUi() dynamically. In this case I use PyQt4. Up to this point no problem.

When I load the form with placed QTreeWidget I want the program to expand all child entries. By default, when I run the program I only see the parent entries. When I want to see the child entries I have to click on the parent entries, but I don't want this.

Is there a way to solve this?

Upvotes: 2

Views: 5546

Answers (1)

ekhumoro
ekhumoro

Reputation: 120798

There is an expandAll() method, which QTreeWidget inherits from the QTreeView class. So, after calling loadUi(), just add something like this:

  self.treewWidget.expandAll()

Upvotes: 5

Related Questions