c++ - How to get the files that not appear in the QTreeView -
c++ - How to get the files that not appear in the QTreeView -
i'm utilize qtreeview
setfilter()
function allow display directories , drivers files not allowed.
but want files don't appear in qtreeview
, go on display directories , drivers without files in qtreeview
.
qfilesystemmodel dirsmodel = new qfilesystemmodel; dirsmodel->setrootpath(""); ui->treeview->setmodel(dirsmodel); dirsmodel->setfilter(qdir::alldirs | qdir::nodotanddotdot);
how can ?
as said before need entrylist
. example:
void mainwindow::on_pushbutton_clicked() { qmodelindex ind = ui->treeview->currentindex(); qfilesystemmodel *sys = qobject_cast<qfilesystemmodel*>( ui->treeview->model()); qstring path = sys->filepath(ind); qdebug() << path; qdir dir(path); qstringlist files = dir.entrylist(qstringlist(), qdir::files); if(!files.size()) qdebug()<< "empty"; else for(int i=0 ; i<files.size();i++) qdebug() << files.at(i); }
we used qfilesystemmodel
here current path, entrylist
absolutely separate this.
c++ qt qt5
Comments
Post a Comment