QT implements a multi-level drop-down list navigation menu, which can be folded (QTreewidget implementation)

Table of contents

Create multi-level lists

Drag a QTreewidget control into the ui.

Double-click the control to open the Edit Tree widget. ​Edit​Edit

Make list control settings:

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

  1. Drag a QTreewidget control into the ui.

  2. Double-click the control to open the Edit Tree widget.

  3. 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.

 

 

 

 

Guess you like

Origin blog.csdn.net/weixin_55735677/article/details/130075574