Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] Expanding wildcards in directory paths



  • I'm a newbie to C++/Qt.

    Looking at the docs for QDir, one can filter for a "type" of file (eg: *.txt) however can QDir expand wildcards in the path?

    For example if I have the following dir structure:
    @
    foo
    -> bar
    -> one.txt
    -> two.txt
    @
    If I was above foo, and wanted to find foo//.txt how would one do it with QDir? Is it even possible? Or would I have to do a manual walk over the segments in the path?



  • I think you will have to walk through the children manually because QDir only display its direct child nodes in the filesystem.



  • You will have to manually walk through the subdirs. For filtering, have a look at "QDir::entryInfoList() ":http://doc.qt.nokia.com/4.7/qdir.html#entryInfoList



  • Thanks guys. I've already begun code to manually walk the subdirs. It would be a nice feature to have in QDir of course ;)


Log in to reply