franki
4th December 2013, 11:42
Hi all,
I need to pass reference to: QMap<int,QList<int> > myMap
to function that should fill it in, so I did:
QMap<int,QList<int> > myMap;
this->myFunction(..other_vars...,&myMap);
inside function
void myFunction(..other_vars..,QMap<int,QList<int> > *myMap) {
if(!myMap->contains(actor_type))
myMap->insert(actor_type,QList<int>());
if(!myMap[actor_type].contains(actor_id))
myMap[actor_type].append(actor_id);
}
there is problem in last line:
error: 'class QMap<int, QList<int> >' has no member named 'append'
so I think second to last line is also problematic, but QMap and QList both have function "contains".
In short words, how to access QList elements within QMap when I passed reference to QMap ?
I could use myMap->value(actor_type) - but this returns const
best regards
Marek
Added after 11 minutes:
sorry for this lame question,
last two lines should be:
[CODE]
if(!(*myMap)[actor_type].contains(actor_id))
(*myMap)[actor_type].append(actor_id);
[CODE]
then it works.
cheers
Marek
I need to pass reference to: QMap<int,QList<int> > myMap
to function that should fill it in, so I did:
QMap<int,QList<int> > myMap;
this->myFunction(..other_vars...,&myMap);
inside function
void myFunction(..other_vars..,QMap<int,QList<int> > *myMap) {
if(!myMap->contains(actor_type))
myMap->insert(actor_type,QList<int>());
if(!myMap[actor_type].contains(actor_id))
myMap[actor_type].append(actor_id);
}
there is problem in last line:
error: 'class QMap<int, QList<int> >' has no member named 'append'
so I think second to last line is also problematic, but QMap and QList both have function "contains".
In short words, how to access QList elements within QMap when I passed reference to QMap ?
I could use myMap->value(actor_type) - but this returns const
best regards
Marek
Added after 11 minutes:
sorry for this lame question,
last two lines should be:
[CODE]
if(!(*myMap)[actor_type].contains(actor_id))
(*myMap)[actor_type].append(actor_id);
[CODE]
then it works.
cheers
Marek