Pretty nice & effective piece of code : ) but in that way,I don't have total control over "the data" of the squares. For example, I won't be able to tell if the square is white,black, occupied or not.
Thank you very much for your effort, but I fixed the error finally by straight luck
.
Problems were :
1-Dynamic cast : I didn't typecast the fetched element from the scene.
2-The painting : here's the code ,
looks like the items moved, but were invisible xD, because of the QRectF return value (which is nothing), so everything was getting re-drawn in small pixels (very small).
QRectF BoardSquare
::boundingRect() const {
return QRectF(0,
0,
30,
30);
//Here was the error, QRectF ( ) was the return value, then I fixed it to QRectF(0,0,30,30)
}
{
painter->drawImage(s,*g);
}
QRectF BoardSquare::boundingRect() const
{
return QRectF(0,0,30,30); //Here was the error, QRectF ( ) was the return value, then I fixed it to QRectF(0,0,30,30)
}
void BoardSquare:: paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
QPoint s;
painter->drawImage(s,*g);
}
To copy to clipboard, switch view to plain text mode
Conclusion of the error & debugging :
The fetched item was a copy, not the real one, fetched and redrawn in a very small size. After using the "Dynamic cast", I was capable of returning the original element.
Afrer fixing the returned value from BoundingRect () function, the item was redrawn perfectly .
Thanks norobro for you effort : ) I will sure put your help into use & consideration in the future.
Bookmarks