I had an object of a Circle, it contains the properties to draw it like width, coor xy, color. I had a qlist of this circles(objects) but when i try to change the color i get an error.
class Circle {
int x;
int y;
int width;
QColor color
}
QList <Circle> circles;
I add some circles to the list here is the problem
circles.at(3).color = Qt::yellow;
passing ‘const QColor’ as ‘this’ argument of ‘QColor& QColor::operator=(Qt::GlobalColor)’ discards qualifiers [-fpermissive]
The at()
function of a QList
returns a const reference: const T & QList::at(int i) const
, so you can not modify it. Use operator[]
instead: circles[3].color = Qt::yellow
Also note that right now all members of your class are private
(by default), so you will not be able to set color
anyway.