【发布时间】:2013-09-30 07:42:23
【问题描述】:
对于其他类型,我可以轻松地做类似的事情
mitm.created().toString("yyyy-MM-dd")
有没有类似的函数可以将 qint64 转为 QString?您可以在下面找到代码。
fileArray.append("[");
foreach(QFileInfo mitm, mDir.entryInfoList(QDir::Files)){
fileArray.append("{\"filePath\": \"");
fileArray.append(mitm.absoluteFilePath());
fileArray.append("\",");
fileArray.append("\"fileCreated\": \"");
fileArray.append(mitm.created().toString("yyyy-MM-dd"));
fileArray.append("',");
fileArray.append("'fileSize': '");
// fileArray.append(mitm.size());
fileArray.append("\"}");
if(fileCount!=mDir.entryInfoList(QDir::Files).count()-1){ fileArray.append(","); }
fileCount++;
}
fileArray.append("]");
我已经注释掉了破坏代码的行。我对日期有同样的问题,但使用 toString 来转换它。我希望 qint64 也有类似的解决方案。
【问题讨论】:
-
您是想将其转换为日期字符串,还是获取数字的字符串表示形式?
-
我正在尝试将其转换为包含文件大小的字符串。我不确定如何将建议的答案应用到我的代码中。