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.