Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am doing this for creating my Qfilesystemmodel :</p> <pre><code>QFileSystemModel *fileSystemModel = new QFileSystemModel(this); fileSystemModel-&gt;setRootPath(path); QStringList filters; filters &lt;&lt;"*.jpeg" &lt;&lt;"*.pict" &lt;&lt;"*.PICT"; fileSystemModel-&gt;setNameFilters(filters); fileSystemModel-&gt;setNameFilterDisables(0); ui-&gt;treeView_2-&gt;setModel(fileSystemModel); ui-&gt;treeView_2-&gt;setRootIndex(fileSystemModel-&gt;index(path)); ui-&gt;treeView_2-&gt;setColumnWidth(0,300); connect(fileSystemModel,SIGNAL(directoryLoaded(QString)),this,SLOT(onDirLoaded(QString))); void MainWindow::onDirLoaded(QString path) { QFileSystemModel *fileSystemModel=(QFileSystemModel*)ui-&gt;treeView_2-&gt;model(); QModelIndex index = fileSystemModel-&gt;index(path); QStringList filters; filters &lt;&lt;"*.jpeg" &lt;&lt;"*.pict" &lt;&lt;"*.PICT"; fileSystemModel-&gt;setNameFilters(filters); fileSystemModel-&gt;setNameFilterDisables(0); int rowCount = fileSystemModel-&gt;rowCount(index); for(int i=0;i&lt;rowCount;i++) { QModelIndex mi = fileSystemModel-&gt;index(i,0,index); QFileInfo fileInfo = fileSystemModel-&gt;fileInfo(mi); if (!templist.contains(fileInfo.absoluteFilePath())) { templist &lt;&lt; fileInfo.absoluteFilePath(); tempNamelist &lt;&lt; fileInfo.fileName(); } if(!bloaded) { if(fileSystemModel-&gt;hasChildren(mi)) { QModelIndex index1 = fileSystemModel-&gt;index(i,0,index); int rowCount1 = fileSystemModel-&gt;rowCount(index1); if(rowCount1) { onDirLoaded(fileInfo.absoluteFilePath()); } } } } } </code></pre> <p>using this i am able to create Qfilsystemmodel but it also shows those subfolders which don't have filtered files. I don't want to show those subfolders. your help will really appreciate.</p> <p>Thanks,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload