我的代码是:
void Tests::writeResultsFile(QString &logTestResults, QString
&combinedResultsS, double &combinedResultsN, QString &deviceId)
{
QFile file(logTestResults); //open test results file
QString convertedNumbersResults[12];
for (int i = 0; i < 12; i++)
{
//below line doesn't work as is
convertedNumbersResults[i] = QString::number(combinedResultsN[i],'f',2);
}
file.remove();
}
file.close();
}
编译时我收到此错误:“C2109:下标需要数组或指针类型”
答案 0 :(得分:-1)
想出了问题,正如@eyllanesc雄辩而礼貌地指出的那样,我正在错误地传递我的数组。
正确的方法:
void Tests::writeResultsFile(QString &logTestResults, QString
combinedResultsS[2], double combinedResultsN[12], QString &deviceId)
{
QFile file(logTestResults); //open test results file
QString convertedNumbersResults[12];
for (int i = 0; i < 12; i++)
{
//below line works now
convertedNumbersResults[i] = QString::number(combinedResultsN[i],'f',2);
}
file.remove();
}
file.close();
}