title: How to use QPainter on QPixmap
body: <p>I'm a newbie to Qt/Embedded. I want to use <code>QPainter</code> to draw stuff on a <code>QPixmap</code>, which will be added to <code>QGraphicsScene</code>. Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap.</p>
  
  <pre><code>int main(int argc, char **argv) {
  
    QApplication a(argc, argv);
  
    QMainWindow *win1 = new QMainWindow();
    win1-&gt;resize(500,500);
    win1-&gt;show();
  
  
    QGraphicsScene *scene = new QGraphicsScene(win1);
    QGraphicsView view(scene, win1);
    view.show();
    view.resize(500,500);
  
    QPixmap *pix = new QPixmap(500,500);
    scene-&gt;addPixmap(*pix);
  
    QPainter *paint = new QPainter(pix);
    paint-&gt;setPen(*(new QColor(255,34,255,255)));
    paint-&gt;drawRect(15,15,100,100);
  
    return a.exec();
  }
  </code></pre>