title: Qt drawPixmap isn't drawing what I expect
body: <p>I'm trying to make a Paint application in C++ with Qt. Everytime I click or click &amp; drag the mouse, the program will draw something on a pixmap. After that, it updates the window calling paintEvent(), which will draw the pixmap onto the window.</p>
  
  <pre><code>void QPaintArea::mousePressEvent(QMouseEvent *event){
      startpoint = event-&gt;pos();
      drawPoint(startpoint);
      is_pressed = true;
  }
  
  void QPaintArea::mouseReleaseEvent(QMouseEvent *event){
      is_pressed = false;
  }
  
  void QPaintArea::mouseMoveEvent(QMouseEvent *event){
      if(is_pressed == true){
          endpoint = event-&gt;pos();
          drawLine(startpoint, endpoint);
          startpoint = endpoint;
      }
      else{
          return;
      }
  }
  
  void QPaintArea::paintEvent(QPaintEvent *event){
      QDesktopWidget *desktop = QApplication::desktop();
      int x = (desktop-&gt;width() - 800) / 2;
      int y = (desktop-&gt;height() - 600) / 2;
      QPainter painter(this);
      QRect target(QPoint(x, y - 35), QSize(800, 600));
      QRect dirtyrect(QPoint(0,0), QSize(800, 600));
      painter.drawPixmap(target, *pixmap, dirtyrect);
  }
  </code></pre>
  
  <p>The problem is that, the program is not printing the pixmap onto the window as expected. For example, I press the mouse at x: 17, y: 82 trying to draw something. The program will print what I drew but at an offset location, like x + 20, y.</p>
  
  <p>Maybe I don't fully understand how QRect or drawPixmap works, but the pixmap is 800x600. "dirtyrect" is supposed to save the entire pixmap (starting a x: 0, y: 0, and the size 800x600). </p>