我有一個QHash<QString, QVector<float> > qhash
,並試圖overwite在QVector
值如下:QHash的QVectors
void Coordinate::normalizeHashElements(QHash<QString, QVector<float> > qhash)
{
string a = "Cluster";
float new_value;
float old_value;
const char *b = a.c_str();
float min = getMinHash(qhash);
float max = getMaxHash(qhash);
QHashIterator<QString, QVector<float> > i(qhash);
while (i.hasNext())
{
i.next();
if(i.key().operator !=(b))
{
for(int j = 0; j<i.value().size(); j++)
{
old_value = i.value().at(j);
new_value = (old_value - min)/(max-min)*(0.99-0.01) + 0.01;
i.value().replace(j, new_value);
}
}
}
}
我在i.value().replace(j, new_value);
行程說法得到一個錯誤如下:
C:\Qt\latest test\Prototype\Coordinate.cpp:266: error: passing 'const QVector' as 'this' argument of 'void QVector::replace(int, const T&) [with T = float]' discards qualifiers [-fpermissive]
任何人都可以幫我解決這個問題?
非常感謝您的回覆。我會盡快完成並留下反饋意見。 – SuTron
感謝您的寶貴迴應。它爲我工作! – SuTron
@MikaelEgibyan不客氣。不要忘記接受有用的答案:http://stackoverflow.com/help/accepted-answer :-) –