Skip to content

Commit

Permalink
Doc: provide a code example of QDirIterator's nameFilters parameter
Browse files Browse the repository at this point in the history
Change-Id: I56f9251f17bab0f835979a5feadec1fa896c9d69
Pick-to: 5.15
Reviewed-by: Venugopal Shivashankar <[email protected]>
  • Loading branch information
mitchcurtis committed Aug 24, 2020
1 parent 7127bf1 commit 0c52e60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/corelib/doc/snippets/code/src_corelib_io_qdiriterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ while (it.hasNext()) {
qDebug() << f.fileName() << f.readAll().trimmed().toDouble() / 1000 << "MHz";
}
//! [1]

//! [2]
QDirIterator audioFileIt(audioPath, {"*.mp3", "*.wav"}, QDir::Files);
//! [2]
7 changes: 6 additions & 1 deletion src/corelib/io/qdiriterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,15 @@ QDirIterator::QDirIterator(const QString &path, IteratorFlags flags)
By default, \a flags is NoIteratorFlags, which provides the same behavior
as QDir::entryList().
For example, the following iterator could be used to iterate over audio
files:
\snippet code/src_corelib_io_qdiriterator.cpp 2
\note To list symlinks that point to non existing files, QDir::System must be
passed to the flags.
\sa hasNext(), next(), IteratorFlags
\sa hasNext(), next(), IteratorFlags, QDir::setNameFilters()
*/
QDirIterator::QDirIterator(const QString &path, const QStringList &nameFilters,
QDir::Filters filters, IteratorFlags flags)
Expand Down

0 comments on commit 0c52e60

Please sign in to comment.