c++ - How to modify elements of a QSet? -


i have qset<quadpattern> texture; , modify quadpattern in loop.

foreach not solution because makes copy.

with code :

qmutablesetiterator<quadpattern>  it(texture); while (it.hasnext()) {     it.next();     it.value().setcoordinate(...)); } 

i compilation error :

error: c2662: 'quadpattern::setcoordinate' : cannot convert 'this' pointer 'const quadpattern' 'quadpattern &' conversion loses qualifiers 

the function setcoordinate :

inline void setcoordinate(const std::pair &value) { _coordinate = value; }

why error ?

error because try modify const object returned qmutablesetiterator::value() function.

i believe cannot modify set's items in way, , therefore there no such api. need modify items clearing set , inserting new items again.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -