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.

Qt Code:
  1. QPixmap pixmap = QPixmap(":/images/TexturePattern.png");
  2. QBrush brush = QBrush(QPixmap(pixmap));
  3.  
  4. mainRect = new QGraphicsRectItem(0,0,960,1300);
  5. mainRect->setBrush(brush);
  6. mainRect->setPen(QPen(QBrush(QColor("Gray")), 3));
  7. mainRect->setVisible(true);
  8. 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.