Table of contents
Drag a QTreewidget control into the ui.
Double-click the control to open the Edit Tree widget. EditEdit
Add an icon in front of the item:
Effect:
QT implements multi-level drop-down list, collapsible
When working on a project, you need to implement a collapsible multi-level drop-down list, which can be realized with QTreewidget, and it can be operated directly in the ui file without code.
Create multi-level lists
-
Drag a QTreewidget control into the ui.
-
Double-click the control to open the Edit Tree widget.
-
Make list control settings:
Under Columns, click the plus sign to add a column, and the minus sign to delete a column. Generally, only one column is needed.
Under the project, if you need to add a sub-item, follow the instructions in the figure below. Click the Add Subitem button to create a branch. It takes a few tries to make the list you want.
Add an icon in front of the item:
First put the pictures used in the resource folder, then select the item to which the icon needs to be added, click the property button, find the icon line, click the drop-down button on the right, select the resource, click the picture, and confirm.