【发布时间】:2013-08-17 16:58:37
【问题描述】:
我有一个QHash<QString, QVector<float> > qhash,并试图覆盖QVector 中的值,如下所示:
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: 错误:将 'const QVector' 作为 'void QVector::replace(int, const T&) [with T = float] 的 'this' 参数传递' 丢弃限定符 [-fpermissive]
谁能帮我解决这个问题?
【问题讨论】:
标签: qt replace constants qhash qvector