내 응용 프로그램에 QListView
이 있고 QT 문서에 표시된대로 해당 아이콘이있는 파일 목록을 표시하려고합니다.
QListView 나는 다음과 같은 코드를 가지고있는 Icon mode
에 - 이제QListView에서 파일 아이콘을 볼 수없는 이유는 무엇입니까?
std::vector<std::string>::iterator it = result.begin() ; // got the results, now tie them to the StandardItemModel.
RespPara::stringList = new QStringList ;
RespPara::model = new QStringListModel ;
while(it!=result.end())
{
std::cout<<*it<<std::endl ;
RespPara::stringList->append((*it).c_str()) ;
it++ ;
}
RespPara::model->setStringList(*(RespPara::stringList)) ;
RespPara::mainWindow->listView->setModel(RespPara::model) ;
파일 목록이 기본 응용 프로그램에서 볼 수 있지만, 아이콘이 표시되지 않습니다.
여기서 내가 뭘 잘못하고 있니? 이 문제를 어떻게 해결할 수 있습니까?
편집 : - :
여기while(!in.eof())
{
getline(in, buff) ;
QFileInfo fileInfo(buff.c_str()) ;
QFileIconProvider iconProvider ;
QIcon icon = iconProvider.icon(fileInfo) ;
QStandardItem* standardItem = new QStandardItem(icon, buff.c_str()) ;
myModel->appendRow(standardItem) ;
}
win.listView->setModel(myModel) ;
스크린 샷 : - -이
다음은 모든 유형의 파일에 대해 동일한 아이콘을주고 새로운 코드
당신은 파일 이름에 확장자를 포함나요? – Tay2510
예, 포함 시켰습니다 –
"같은 아이콘"은 무엇입니까? 아마도 스크린 샷이 있을까요? – Tay2510