QWidget *w=new QWidget;
QTreeWidget *treeWidget=new QTreeWidget;
treeWidget->setColumnCount(2);
QStringList head;
head<<QStringLiteral("科目")<<QStringLiteral("分数");
treeWidget->setHeaderLabels(head);
QStringList student1;
student1<<QStringLiteral("张三");
QTreeWidgetItem *student1root=new QTreeWidgetItem(treeWidget,student1);
QStringList student2;
student2<<QStringLiteral("李四");
QTreeWidgetItem *student2root=new QTreeWidgetItem(treeWidget,student2);
QStringList student1Info;
student1Info<<QStringLiteral("语文")<<"100";
QTreeWidgetItem *student1In=new QTreeWidgetItem(student1root,student1Info);
QStringList student2Info;
student2Info<<QStringLiteral("数学")<<"90";
QTreeWidgetItem *student2In=new QTreeWidgetItem(student2root,student2Info);
QHBoxLayout *layout=new QHBoxLayout;
layout->addWidget(treeWidget);
w->setLayout(layout);
w->show();