实现过程:
QTreeWidgetItem *item = new QTreeWidgetItem; //svg_path为SVG图片路径 QSvgRenderer *svg_render = new QSvgRenderer(svg_path); QPixmap *pixmap = new QPixmap(32, 32); pixmap->fill(Qt::transparent); QPainter painter(pixmap); svg_render->render(&painter); QIcon ico(*pixmap); item->setIcon(1, ico);