Hi,
when using my custom QGraphicsItemi get artifacts in the GraphicsView.
The artifacts appear when i "zoom out" by caling graphicsView->scale(0.2,0,2). Without scaling i don't see the artifacts.
I have a 5x5 grid of my GraphicsItem objects, and the upper left is the parent of the other ones.
I draw the bounding rects and they look good.
Here is my paint method:
Q_UNUSED(widget);
painter->save();
if(!pixels.isNull()) {
painter
->drawPixmap
(QRect(0,
0,w,h
), pixels, pixels.
rect());
}
painter->drawRect(boundingRect());
painter->restore();
}
void Tile::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(widget);
painter->save();
if(!pixels.isNull()) {
painter->drawPixmap(QRect(0,0,w,h), pixels, pixels.rect());
}
painter->drawRect(boundingRect());
painter->restore();
}
To copy to clipboard, switch view to plain text mode
and my bounding rect method:
QRectF Tile
::boundingRect() const {
if(childItems().empty()) {
return QRectF(-50,
-50,w
+100,h
+100);
} else {
return QRectF(-100,
-100,
5*w
+200,
5*h
+200);
}
}
QRectF Tile::boundingRect() const {
if(childItems().empty()) {
return QRectF(-50,-50,w+100,h+100);
} else {
return QRectF(-100,-100,5*w+200,5*h+200);
}
}
To copy to clipboard, switch view to plain text mode
I searched this forum and the web for solutions, but i couldn't solve it yet. Any ideads?
Any idea?
Cheers,
Thomas
Bookmarks