Hi all,
I would like to add a rectangle with a textured brush pattern to a QGraphicsScene. However, the rendering is not working out for some reason.
Here's the code where I add the rectangle to the scene.
mainRect->setBrush(brush);
mainRect->setVisible(true);
addItem(mainRect);
QPixmap pixmap = QPixmap(":/images/TexturePattern.png");
QBrush brush = QBrush(QPixmap(pixmap));
mainRect = new QGraphicsRectItem(0,0,960,1300);
mainRect->setBrush(brush);
mainRect->setPen(QPen(QBrush(QColor("Gray")), 3));
mainRect->setVisible(true);
addItem(mainRect);
To copy to clipboard, switch view to plain text mode
Here's a piece of the resulting image:
BadPattern.png
I substituted my image into the Painting example Basic Shapes, (substituted texturePattern.png for Brick.png) and it seems to render just fine:
OkPattern.jpg
Other than their using a Widget and I'm using a QGraphicsScene, I can't seem to find any difference in the code. Does anyone know why?
Thanks in advance.
Bookmarks