PDA

View Full Version : Error with QMap



xgoan
17th November 2008, 11:45
Hi,

I have this problem with this function:


void ImageLandmarkProxyModel::countRowsInserted(const QModelIndex &parent, int start, int end) const
{
const int idImageColumn=sourceModel()->column(
ImageLandmarkTableModel::IdImage);
const int idPointColumn=sourceModel()->column(
ImageLandmarkTableModel::IdPoint);
qDebug()<<"Rows inserted";
for(int i=start;i<=end;i++)
{
QModelIndex col1=sourceModel()->index(i, idImageColumn);
QModelIndex col2=sourceModel()->index(i, idPointColumn);
bool ok;
int id=col1.data().toInt(&ok);
Q_ASSERT(ok);
if(m_rowCount.contains(id)){
m_rowCount[id]=1;
// m_rowCount[id]=m_rowCount.value(id)+1;
}
else{
// m_rowCount.insert(id, col2.data().isNull() ? 0 : 1);
}
}
qDebug()<<m_rowCount;
}
src\imagelandmarkproxymodel.cpp:101: error: non-lvalue in assignment

in line: m_rowCount[id]=1;

m_rowCount is a QMap<int,int>

Thanks

xgoan
17th November 2008, 12:07
Solved the problem was that I use const in the function definition :)