1.Qt 5.10 新增 setFileTime() 方法。
2.有创建、修改、访问三个时间需要修改。
3.必须打开文件才能修改时间成功。
if (QFile::copy(filepath, filepath_new)) {
qDebug() << "copy" << filepath << filepath_new;
#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0))
QFile file(filepath_new);
file.open(QIODevice::ReadOnly);
qDebug() << "克隆文件创建时间" << file.setFileTime(QFileInfo(filepath).birthTime(), QFileDevice::FileBirthTime);
qDebug() << "克隆文件修复时间" << file.setFileTime(QFileInfo(filepath).lastModified(), QFileDevice::FileModificationTime);
qDebug() << "克隆文件访问时间" << file.setFileTime(QFileInfo(filepath).lastRead(), QFileDevice::FileAccessTime);
file.close();
#endif
}