How to identify whether an item is a file or a folder in QT

1.8k Views Asked by At

I wanted to specify from a path, whether the item is a file or a folder. How can I implement such function which takes a path (QString based input) and tells whether it is a file or folder?

1

There are 1 best solutions below

0
Waqar On BEST ANSWER

You can use the method QFileInfo::isFile() or QFileInfo::isDir() to accomplish this.

Example:

QFileInfo fi("/your/path/string");
if (fi.exists() && fi.isFile())
{
   //Do stuff...
}