QTreeWidgetItem *root = new QTreeWidgetItem(ui.treeWidget, QStringList(fileName)); root->setIcon(0, QIcon("./Resources/RsProduct16.gif")); QIcon icon; icon.addPixmap(QPixmap("./Resources/RsGroupOpen16.gif"), QIcon::Normal, QIcon::On);//节点打开状态 icon.addPixmap(QPixmap("./Resources/RsGroupClosed16.gif"), QIcon::Normal, QIcon::Off);//节点关闭状态 //metadata QTreeWidgetItem *leafMetadata = new QTreeWidgetItem(root, QStringList(QString(tr("Metadata"))));
leafMetadata->setIcon(0, icon);
root->addChild(leafMetadata); //bands QTreeWidgetItem *leaf2 = new QTreeWidgetItem(root, QStringList(QString(tr("Bands")))); leaf2->setIcon(0, icon); root->addChild(leaf2);