对于其他类型我可以很容易地做类似的事情
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 也有类似的解决方案。
最佳答案
您可能正在寻找 QString::number(qlonglong, int)
.
关于c++ - 将 qint64 转换为 QString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18992654/