下面的这个函数中就有设置图标的,呵呵,这是我自己写的一个项目中的东西,呵呵,你参考一下吧
void MainWindowFrm::on_openImage()
{
QString strName = QFileDialog::getOpenFileName(this,"选择影像文件",QDir::currentPath(),"JPEG(*.jpg);;JPEG2000 (*.jp2);;TIFF(*.tif);;Image(*.img)");
if (!strName.isEmpty())
{
if(centralView.getDocument()->openImage(strName))
{
MainFrmDoc * pdoc = centralView.getDocument();
centralView.setWinFrm(pdoc->getImageMinUPX()-100,pdoc->getImageMinUPY()-100,pdoc->getImageMaxExtend()+200);
QFileInfo FInfo(strName);
QTreeWidgetItem *TwiManage = new QTreeWidgetItem(imageParent);
QFileInfo Finfo(strName);
TwiManage->setIcon(0,QIcon(":/images/FV.png"));
TwiManage->setText(1,Finfo.suffix().toUpper()+"-"+Finfo.baseName().toUpper());
treeManage->update();
}
}
else
{
QMessageBox::information(¢ralView,"文件消息","没有选择影像文件,\n\n请重新选择!");
}
treeManage->update();
}