Hi there,

You can compare their absolute paths.


#include <QCoreApplication>

#include <QDir>

#include <QDebug>


int main(int argc, char *argv[])

{

    QCoreApplication app(argc, argv);


    QDir a("/Users/olegyadrov/one/two/three");

    QDir b("/Users/olegyadrov/one/two");

    QDir c("/Users/olegyadrov/one/four");


    qDebug() << a.absolutePath().startsWith(b.absolutePath());

    qDebug() << a.absolutePath().startsWith(c.absolutePath());


    return app.exec();

}


outputs

true
false

Best regards,
Oleg Yadrov - oleg.yad...@qt.io<mailto:oleg.yad...@qt.io>

On Jul 11, 2018, at 5:04 AM, Tom Isaacson via Interest 
<interest@qt-project.org<mailto:interest@qt-project.org>> wrote:

Is there any way of finding if one QDir is a subdirectory of another? So for 
instance:
C:\One\Two\Three
is a subdirectory of:
C:\One\Two
but not of:
C:\One\Four

Thanks.

Tom Isaacson

_______________________________________________
Interest mailing list
Interest@qt-project.org<mailto:Interest@qt-project.org>
http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to