Reputation: 2113
I tried to create a simple treeview with the following code in Qt 4.8
QTreeWidgetItem *city = new QTreeWidgetItem(ui->trvCompetitions);
city->setText(0, tr("City"));
(new QTreeWidgetItem(city))->setText(0, tr("Stockholm"));
(new QTreeWidgetItem(city))->setText(0, tr("Helsinki"));
(new QTreeWidgetItem(city))->setText(0, tr("Copenhagen"));
QTreeWidgetItem *other = new QTreeWidgetItem(ui->trvCompetitions);
other->setText(0, tr("Other"));
(new QTreeWidgetItem(other))->setText(0, tr("London"));
(new QTreeWidgetItem(other))->setText(0, tr("Tokio"));
(new QTreeWidgetItem(other))->setText(0, tr("Hanoi"));
And this is the treeview I got
I have read this article and I only want my treeview has expand/collapse sub-items like that
How can I change my treeview like this?
Thank!
Upvotes: 1
Views: 2632