Hi,

I have a problem with QPrintPreviewDialog in Windows 8.1 environment. When I open it, it just has a grey background, without any pages on it. If I actually send a print job from the dialog though, it prints properly. Also, the problem only seems to appear on Windows 8 - it shows up fine in Windows 7. Here's the code that opens the preview dialog:

Qt Code:
  1. QPrinter printer(QPrinter::ScreenResolution);
  2. printer.setPaperSize(QPrinter::A4);
  3. printer.setFullPage(true);
  4. QPrintPreviewDialog preview(&printer);
  5. connect(&preview, SIGNAL(paintRequested(QPrinter *)), this, SLOT(print(QPrinter *)));
  6. preview.setMinimumHeight(500);
  7. preview.exec();
To copy to clipboard, switch view to plain text mode 

And the print() slot contains this (among other layouting code):

Qt Code:
  1. ...
  2. QPainter painter( printer );
  3. painter.setRenderHint(QPainter::Antialiasing);
  4.  
  5. int w = printer->pageRect().width();
  6. int h = printer->pageRect().height();
  7. QRect region( 0, 0, w, h );
  8. QRectF diagramSize(region.left(),region.top(),region.width(), region.height());
  9.  
  10. //scene is a QGraphicsScene
  11. scene->render(&painter,diagramSize,scene->itemsBoundingRect());
To copy to clipboard, switch view to plain text mode 

Any ideas as to why it might be happening?

Thanks in advance