QStandardItemModel* model = new QStandardItemModel(ui.treeView);
model->setHorizontalHeaderLabels(QStringList() << QStringLiteral("项目名") << QStringLiteral("信息"));
QStandardItem* itemProject = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("项目"));
model->appendRow(itemProject);
model->setItem(model->indexFromItem(itemProject).row(), 1, new QStandardItem(QStringLiteral("项目信息说明")));
QStandardItem* itemFolder = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("文件夹1"));
itemProject->appendRow(itemFolder);
itemProject->setChild(itemFolder->index().row(), 1, new QStandardItem(QStringLiteral("信息说明")));
itemFolder = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("文件夹2"));
itemProject->appendRow(itemFolder);
itemProject->setChild(itemFolder->index().row(), 1, new QStandardItem(QStringLiteral("文件夹2信息说明")));
itemProject = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("项目2"));
model->appendRow(itemProject);
ui.treeView->setModel(model); //这句很重要有很多资源提供者没有写这句,可能是因为我太菜了吧
model->setHorizontalHeaderLabels(QStringList() << QStringLiteral("项目名") << QStringLiteral("信息"));
QStandardItem* itemProject = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("项目"));
model->appendRow(itemProject);
model->setItem(model->indexFromItem(itemProject).row(), 1, new QStandardItem(QStringLiteral("项目信息说明")));
QStandardItem* itemFolder = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("文件夹1"));
itemProject->appendRow(itemFolder);
itemProject->setChild(itemFolder->index().row(), 1, new QStandardItem(QStringLiteral("信息说明")));
itemFolder = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("文件夹2"));
itemProject->appendRow(itemFolder);
itemProject->setChild(itemFolder->index().row(), 1, new QStandardItem(QStringLiteral("文件夹2信息说明")));
itemProject = new QStandardItem(QIcon(":/FileServer/image/open_focus.png"), QStringLiteral("项目2"));
model->appendRow(itemProject);
ui.treeView->setModel(model); //这句很重要有很多资源提供者没有写这句,可能是因为我太菜了吧