简体   繁体   中英

Loop through all items with desired file extension on QTreeView + QFileSystemModel

I'm completely newbie to Qt and C++, so I guess this is a very basic question, but I couldn't find it anywhere!

I'm using a QTreeView together with a QFileSystemModel to show the contents of a folder. When I need to loop though all selected items on it, I just use:

foreach (QModelIndex index, treeView->selectionModel()->selectedRows()) 
{
    //...
}

My question is:

Is there a similar way to loop through all items with desired file extension (for instance, *.aaa files)? If it can't be done exactly like this, please tell me how!

Edit: Just to make it clear, I'd want to loop through ALL files with given extension, not only the selected ones

Thanks in advance!

Using rowCount, columnCount and hasChildren, one should be able to run over all the elements of an QAbstractItemModel. Does it help you?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM