What is the API to search for a folder/directory without iterating all children

  • Hi,

    I want to search for a directory under given path on Linux. But, I don't want to iterate all folders and compare directory for each iterator.

    Is there any smart way to find the folder with Qt? (I expect, like spotlight apis on mac)


  • Moderators

    If you mean a search query that calls you back on find then there's no such thing in Qt, but you can easily construct such a class. Call QDir::entryList for a base directory and use contains() on the resulted list. If it's there emit a signal. If not recursively call it on each sub-directory. Shouldn't be much of a hassle.

  • Thank you.

    If desired directory is leaf node and tree has so much depth on linux file system, then it would give performance issue. If already indexed for file system, then it's easy to find the entry from database. It shouldn't take long time to find directory. I have find directory in button click event. Any solution?

  • Moderators

    I'm not a linux guy so I won't be of much help, but if all else fails you can always QProcess whatever linux command you think will be the fastest.

Log in to reply

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