Exclude files with QFileInfoList filter



  • Hello,
    When using QFileInfoList + QDir, can we filter anythinbg that should be excluded (or does the filtering is only on what is included) ?
    For example:

    1. Can I filter the . , .. files (so that they are excluded from list) ?
    2. Can I filter all files that have some substr in the name such as "garbage" string: xxx_garbage_xxx (so that they are excluded from list) ?

    Thank you,
    Ran


  • Moderators

    As the "documentation":http://doc.qt.io/qt-5/qdir.html#entryInfoList suggests: yes, you can filter the results as you wish.

    Example:
    @
    QFileInfoList list = dir.entryInfoList("*.exe", QDir::NoDotAndDotDot | QDir::Files);

    // or just
    QFileInfoList list = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files);
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.