I use Qt 4.4.0 and I have a dockWidget which includes a label and a QwtPlot (Qwt 5.1.0) in a layout.
I'm trying to print the dockWidget into a .pdf but I have a problem with the size of the printed widget.

The resulting .pdf shows the dockWidget (label and plot) but it doesn't use the whole page. If I change the size of the dockWidget before printing, the printed dockWidget size changes as well (but not taking the full page size).
When the renderFlags are set to (DrawWindowBackground | DrawChildren) The background takes the whole page but the window doesn't.

This is the relevant bit of my code. I'll be happy to consider any other ways of printing my dockWidget.

Qt Code:
  1. QPrinter printer;
  2. int w = printer.width();
  3. int h = printer.height();
  4. QRegion region(0,0,w,h);
  5. QPainter p(&printer);
  6. dockWidget_->render(&p, QPoint(), region);
To copy to clipboard, switch view to plain text mode