I am trying to apply the foreach keyword to my code, which does a lot of iterations over QLists containing objects of types inherited from QGraphicsItem.
So first problem was foreach requiring some methods (copy constructor, "=" operator) that I had not implemented in my child class.
So I implemented these. But then I run into problems with the assignment operator. AFAIK the child assignment operator should call the base class operator to ensure that base part of the object is properly assigned. But when I call it
myClass& operator=( const myClass& rightHand ) {
if ( &rightHand != this )
{
// ...my assignment stuff here.
}
return *this;
}
myClass& operator=( const myClass& rightHand ) {
if ( &rightHand != this )
{
QGraphicsItem::operator =( rightHand );
// ...my assignment stuff here.
}
return *this;
}
To copy to clipboard, switch view to plain text mode
the compiler tells me that
'QGraphicsItem& QGraphicsItem::operator=(const QGraphicsItem&)' is private
So what is the proper way to have a class derived from QGraphicsItem that I can use with foreach( myClass x, QList<myClass> y) ?
Bookmarks