QTreeWidgetItem* item = new QTreeWidgetItem(); QIcon icon(":/images/folder_icon.png"); item->setText(0, "Folder"); item->setIcon(0, icon);
QTreeWidgetItem* item = new QTreeWidgetItem(); QPixmap pixmap(":/images/file_icon.png"); QIcon icon(pixmap); item->setText(0, "File"); item->setIcon(0, icon);In this example, another new item is created, and an icon is set for it using the setIcon() method. The icon is created from a QPixmap object using the QIcon class. The QTreeWidgetItem class is a part of the QtGui module in the Qt framework.