[Qt-interest] QFile::exists on a folder

Ender EREL erelender at yahoo.com
Thu Feb 11 10:48:17 CET 2010


You can use QFileInfo to distinguish between dirs and files.

void myClass::openFile(const QString & _file)
{
   QFileInfo fileInfo(_file);
   if(fileInfo.isFile())
   {
       QFile fileToOpen(_file);
     if(fileToOpen.exists() == false)
     {
        printf("Error file:\"%s\" doesn't exist", 
_file.toStdString().c_str());
     }
     ....
   }
}

-- 
Ender EREL



More information about the Qt-interest-old mailing list