title: QGraphicsView to pdf
body: <p>I have a big scene successfully displayed in my window with the help of <code>QGraphicsView/QGraphicsScene</code> with scroll bars for navigation. Everything works fine. </p>
  
  <p>Now I would like now to render part of the scene in a pdf. The region to be render in the pdf should be the area visible in the window and the rectangles above and under the visible area. </p>
  
  <p>I've tried that (to begin simply, I've ignored if horizontal scroll bar have been used) : </p>
  
  <pre><code>QPrinter myPrinter(QPrinter::ScreenResolution); 
  myPrinter.setOrientation(QPrinter::Landscape);
  myPrinter.setPaperSize(QPrinter::A4);
  myPrinter.setOutputFormat(QPrinter::PdfFormat);
  myPrinter.setPageMargins(0.0, 0.0, 0.0, 0.0, QPrinter::Point);
  
  QPainter myPainter(&amp;myPrinter);
  m_pageWidth = myPrinter.width();
  m_pageHeight = myPrinter.height();
  myPainter.setViewport(0, 0, m_pageWidth, m_pageHeight);
  
  QRectF viewRender = QRect(0.0, 0.0, m_pageWidth, m_pageHeight);
  
  for(int i = 0; i &lt; myScene-&gt;getNbPages(); i++)
  {
      QRect viewScene = QRect(0, m_pageHeight * i, m_pageWidth, m_pageHeight);
      setSceneRect(viewScene);
  
      render(&amp;myPainter, viewRender, viewScene);
  
      if(i + 1 &lt; myScene-&gt;getNbPages())
          myPrinter.newPage();
  }
  </code></pre>
  
  <p>But I don't get result as I would expect. For example in this function <code>QGraphicsView::drawBackground(QPainter *painter, const QRectF &amp;rect)</code> rect's top left corner is not at 0, 0 for the first page, but a 107, 98, then at 107, 1585 (but page height is only 793 ?!) and so on...</p>
  
  <p>Anyone understand what is going on ? Thanks for reading. </p>