Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
//------------添加头------------//
QList<QString> list;
list << "英雄名" << "英雄介绍";
ui->treeWidget->setHeaderLabels(QStringList() << "英雄名" << "英雄介绍");
//------------添加项目------------//
// 添加顶层项目
QTreeWidgetItem* Item_Power = new QTreeWidgetItem(QStringList()<< "力量");
QTreeWidgetItem* Item_Quick = new QTreeWidgetItem(QStringList()<< "敏捷");
QTreeWidgetItem* Item_Mental = new QTreeWidgetItem(QStringList()<< "智力");
ui->treeWidget->addTopLevelItem(Item_Power);
ui->treeWidget->addTopLevelItem(Item_Quick);
ui->treeWidget->addTopLevelItem(Item_Mental);
// 追加子项目
QStringList heroP1,heroP2;
heroP1 << "刚背猪" << "前排坦克,能在吸收伤害的同时造成可观的范围输出";
heroP2 << "船长" << "前排坦克,能肉能输出能控场的全能英雄";
QStringList heroQ1,heroQ2;
heroQ1 << "月骑" << "中排物理输出,可攻击多个目标";
heroQ2 << "小鱼人" << "擅长偷取敌人的属性来增强自身";
QStringList heroM1,heroM2;
heroM1 << "死灵法师" << "前排法师坦克,魔法抗性较高,拥有治疗技能";
heroM2 << "巫医" << "后排辅助法师,可以使用奇特的巫术诅咒敌人与治疗队友";
QTreeWidgetItem* P1 = new QTreeWidgetItem(heroP1);
Item_Power->addChild(P1);
QTreeWidgetItem* P2 = new QTreeWidgetItem(heroP2);
Item_Power->addChild(P2);
QTreeWidgetItem* Q1 = new QTreeWidgetItem(heroQ1);
Item_Quick->addChild(Q1);
QTreeWidgetItem* Q2 = new QTreeWidgetItem(heroQ2);
Item_Quick->addChild(Q2);
QTreeWidgetItem* M1 = new QTreeWidgetItem(heroM1);
Item_Mental->addChild(M1);
QTreeWidgetItem* M2 = new QTreeWidgetItem(heroM2);
Item_Mental->addChild(M2);
}