title: QPixmap copy contents of a square drawn into another image
body: <p>I have an image onto which I draw a Rectangle as such. After that I am attempting to copy the contents of the rectangle onto another QLabel. This seems to work however i cannot seem to align the copied image starting from the left top corner of the image. Here is what I am doing</p>
  
  <pre><code>QPixmap original_image; 
  original_image.load("c:\\Images\\myimg.jpg");
  original_image = original_image.scaled(ui.label-&gt;size().width(),ui.label-&gt;size().height());
  
  //-----------------------------------------------------------------------
  //Draw rectangle on this
  QPixmap target_two(ui.label-&gt;size().width(),ui.label-&gt;size().height());
  target_two.fill(Qt::transparent);     
  
  QPixmap target(ui.label-&gt;size().width(),ui.label-&gt;size().height());
  target.fill(Qt::transparent);    
  
  QPainter painter(&amp;target);
  QPainter painter_two(&amp;target_two);
  
  
  QRegion r(QRect(0, 0, ui.label-&gt;size().width(), ui.label-&gt;size().height()), QRegion::RegionType::Rectangle);  //Region to start copying
  painter.setClipRegion(r);
  painter.drawPixmap(0, 0, original_image); //Draw the original image in the clipped region 
  
  
  QRectF rectangle(x_start,y_start,clipRegion);
  painter.drawRoundedRect(rectangle,0,0); //Last two parameters define the radius of the corners higher the radius more rounded it is
  
               QRegion r_two(rectangle.toRect(), QRegion::RegionType::Rectangle); 
               painter_two.setClipRegion(r_two);
               painter_two.drawPixmap(0,0,target); 
  
  
  ui.label-&gt;setPixmap(target);    
  
  ui.label_2-&gt;setPixmap(target_two);
  </code></pre>
  
  <p>The bottom picture is the image with the red rectangle in it and that is fine.
  The top picture is a copy of the contents of the square.The only problem is its not starting from the top left corner.</p>
  
  <p>Any suggestion on why I am not getting the copied content on the top left corner.</p>