-1
我必须将文件从源目录复制到目标目录。能否请您做这样的操作如何将文件从源目录复制到qt中的目标目录
我必须将文件从源目录复制到目标目录。能否请您做这样的操作如何将文件从源目录复制到qt中的目标目录
我想类似的东西,并使用Google(白白)提供代码,所以这是我必须:
static bool cpDir(const QString &srcPath, const QString &dstPath)
{
rmDir(dstPath);
QDir parentDstDir(QFileInfo(dstPath).path());
if (!parentDstDir.mkdir(QFileInfo(dstPath).fileName()))
return false;
QDir srcDir(srcPath);
foreach(const QFileInfo &info, srcDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
QString srcItemPath = srcPath + "/" + info.fileName();
QString dstItemPath = dstPath + "/" + info.fileName();
if (info.isDir()) {
if (!cpDir(srcItemPath, dstItemPath)) {
return false;
}
} else if (info.isFile()) {
if (!QFile::copy(srcItemPath, dstItemPath)) {
return false;
}
} else {
qDebug() << "Unhandled item" << info.filePath() << "in cpDir";
}
}
return true;
}
我相信这个问题已经有了答案在这篇文章中:http://stackoverflow.com/questions/2536524/copy-directory-using-qt –
与Qt你的意思是qmake? –