Adding children node to Tree View
#include <QtGui>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QTreeWidget treeWidget;
treeWidget.setColumnCount(1);
QStringList headerLabels;
headerLabels << "Namen";
treeWidget.setHeaderLabels(headerLabels);
QTreeWidgetItem *parent = new QTreeWidgetItem(&treeWidget,QStringList(QObject::tr("A")));
parent->addChild(new QTreeWidgetItem(QStringList(QObject::tr("A"))));
parent->addChild(new QTreeWidgetItem(QStringList(QObject::tr("B"))));
parent->addChild(new QTreeWidgetItem(QStringList(QObject::tr("C"))));
treeWidget.expandItem(parent);
treeWidget.show();
return app.exec();
}
Related examples in the same category