0
QVector <QString> frequency;
QVector <QString> gain;
QString ref_data;
QStringList rowOfData;
QStringList rowData;
if (ReferenceData.open(QIODevice::ReadOnly | QIODevice::Text)) {
ref_data = ReferenceData.readAll();
rowOfData = ref_data.split("\n");
ReferenceData.close();
}
for (int x = 9; x < rowOfData.size(); x++) {
rowData = rowOfData.at(x).split(",");
frequency.push_back(rowData[0]);
gain.push_back(rowData[1]);
}
我從文件中讀取所有數據。當我使用push_back
時,出現錯誤QList<T>::operator[] "index out of range"
。我也用frequency.push_back(rowData.at(0));
,然後我得到QList<T>::at "index out of range"
錯誤!從csv文件插入值到Qt向量時出錯
如何解決這個問題?
什麼是rowData,頻率和增益? – 2013-04-20 20:23:27
我將編輯 – 2013-04-20 20:26:40
您是否在調試器中運行代碼?你檢查過'rowOfData.at(x)'的值嗎?你是否檢查過'rowData'確實包含至少兩個值? – 2013-04-20 20:29:27