#include <sys/utime.h>...QDateTime dt;...#ifdef Q_OS_WIN filePath.replace("/", "\\");#endif struct utimbuf times;times.actime = times.modtime = dt.toTime_t(); utime(filePath.toLatin1().data(), ×);
#ifdef Q_OS_WIN#include <qt_windows.h>#endif ... QDateTime dt; SYSTEMTIME systemTime; FILETIME fileTime, localFileTime; HANDLE hFile;...#ifdef Q_OS_WIN systemTime.wYear = dt.date().year(); systemTime.wMonth = dt.date().month(); systemTime.wDayOfWeek = dt.date().dayOfWeek(); systemTime.wDay = dt.date().day(); systemTime.wHour = dt.time().hour(); systemTime.wMinute = dt.time().minute(); systemTime.wSecond = dt.time().second(); systemTime.wMilliseconds = dt.time().msec(); SystemTimeToFileTime(&systemTime, &localFileTime); LocalFileTimeToFileTime(&localFileTime, &fileTime); filePath.replace("/", "\\"); hFile = CreateFile(filePath.utf16(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); SetFileTime(hFile, &fileTime, &fileTime, &fileTime); CloseHandle(hFile);#endif
#include <utime.h>...QDateTime dt;...#ifdef Q_OS_WIN filePath.replace("/", "\\");#endif struct utimbuf times;times.actime = times.modtime = dt.toTime_t(); utime(filePath.toLatin1().data(), ×);