I am a Qt beginner and just got stuck with the problem. I am looking for a file SomePath/NewDirectoryA/NewFile.kml (NewFile.kml will be the only fi
AFAIK it is not possible to create the file and the directory directly with QFile. You have to first create the directory (QDir::mkpath will create the full path) and then the file (QFile::open).
QString path("SomePath/NewDirectoryA/");
QDir dir; // Initialize to the desired dir if 'path' is relative
// By default the program's working directory "." is used.
// We create the directory if needed
if (!dir.exists(path))
dir.mkpath(path); // You can check the success if needed
QFile file(path + "NewFile.kml");
file.open(QIODevice::WriteOnly); // Or QIODevice::ReadWrite