title: scale a QImage in Qt
body: <p>What the easiest way to draw an image as a background for a <code>QGraphicsRectItem</code>?
  I can set the background as follows but I can't scale the image:</p>
  
  <pre><code> QGraphicsRectItem *enemyItem;
  
   QImage *image = new QImage(":/PaperMario.png");
  
   QBrush *brush = new QBrush(*image);
  
  
   enemyItem = new QGraphicsRectItem();
   enemyItem-&gt;setBrush(*brush);
  
   enemyItem-&gt;setRect(enemy-&gt;getXPos()*30,enemy-&gt;getYPos()*30,30,30);
   scene-&gt;addItem(enemyItem);
  </code></pre>
  
  <p>inside QGraphicsRectItem</p>
  
  <pre><code>void MySquare::setBrush(QColor _color){
      color = _color;
      color_pressed = _color;
      update(); //repaint
  }
  </code></pre>
  
  <p>I have tried it using:</p>
  
  <pre><code>QBrush *brush = new QBrush(*image-&gt;scaled(10));
  </code></pre>
  
  <p>But I'm stuck: doesn't want to compile.
  Is this the way to do it?</p>
  
  <p>Edit: </p>
  
  <pre><code>    QImage *image = new QImage(":/PaperMario.png");
      QImage *scaled_image = new QImage(image-&gt;scaled(35,35,Qt::KeepAspectRatio));
      QBrush *brush = new QBrush(*scaled_image);
  </code></pre>
  
  <p>Does does draw it but it still shows the image multiple times in the drawing
  <img src="https://i.stack.imgur.com/Spzym.png" alt="enter image description here"></p>