我尝试在 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"));
这是我得到的树视图
我已经阅读了这篇文章,我只希望我的树视图有这样的展开/折叠子项
我怎样才能像这样改变我的树视图?
谢谢!