[Qt-interest] qdiriterator

Rohan Prabhu rohan at rohanprabhu.com
Thu Apr 14 21:30:53 CEST 2011


Use:

QDirIterator dirIter("/home/user/path/to/directory",
QStringList(QString("stats*.txt")), QDir::Files);

or, if you intend to read those files as well, and hence would like to
iterator over files which are readable:

QDirIterator dirIter("/home/user/path/to/directory",
QStringList(QString("stats*.txt")), QDir::Files|QDir::Readable);

then simply iterator over the QDirIterator:

while(dirIter.hasNext()) {
    QString filePath = dirIter.next();
    // Do something with filePath
}

Hope it helps.

Regards,
rohan

On Fri, Apr 15, 2011 at 12:40 AM, caius ligarius <caius9090 at gmail.com>wrote:

> I have the path to some parent folder say some QString targetDir.  I would
> like to pick up the latest file (time of creation) which begins with
> "stats*.txt". I think I need to use QDirIterator but I am not sure how I can
> use it for my specific use.
>
> Could somebody please help?
>
> Thanks,
> Caius
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110415/1bbfa85d/attachment.html 


More information about the Qt-interest-old mailing list