Описание тега qtreewidget
QTreeWidget is a class in Qt that provides a tree-like view of data.
This class uses a standard model to hold items, each of them being a QTreeWidgetItem
.
Before adding data into the widget, a column count must be specified with setColumnCount()
function. The widget can also have a header with a section for each of the columns. It also supports column-based sorting.
A simple example of using this class looks like this:
//creating a widget
QTreeWidget *myTreeWidget = new QTreeWidget();
//adding a column to it
myTreeWidget->setColumnCount(1);
//creating a container to temporarily hold the items
QList<QTreeWidgetItem *> itemList;
//filling the container with items
for (int i = 0; i < 10; ++i)
itemList.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
//finally, setting the items into the widget.
myTreeWidget->insertTopLevelItems(0, itemList);
Official documentation can be found here for Qt 4.8 and here for Qt 5.