0
Qt:如何通過路徑創建一個需要導航器的文件?說創建「./gg/ggg./fff/ff/file.dd」如果它不存在?Qt:如何創建一個文件(其路徑所需的directorys)?
Qt:如何通過路徑創建一個需要導航器的文件?說創建「./gg/ggg./fff/ff/file.dd」如果它不存在?Qt:如何創建一個文件(其路徑所需的directorys)?
您可以設置路徑
QDir directory("gg/ggg./fff/ff/file");
那麼你可以創建一個像
QDir().mkdir("MyFolder");
bool QDir::mkdir (const QString & dirName) const
Creates a sub-directory called dirName.
Returns true on success; otherwise returns false.
See also rmdir().
文件夾指http://doc.qt.io/qt-5/qdir.html#mkdir
bool QDir::mkpath (const QString & dirPath) const
Creates the directory path dirPath.
The function will create all parent directories necessary to create the directory.
Returns true if successful; otherwise returns false.
參考http://doc.qt.io/qt-5/qdir.html#mkpath
bool QFile::open (OpenMode mode) [virtual]
Reimplemented from QIODevice::open().
Opens the file using OpenMode mode, returning true if successful; otherwise false.
In WriteOnly or ReadWrite mode, if the relevant file does not already exist, this function will try to create a new file before opening it.
的可能重複[如何遞歸創建Qt中的目錄?(http://stackoverflow.com/questions/6232631/how-to-recursively-create-a-directory-in- QT) – karlphillip