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:
printer.setFullPage(true);
QPrintPreviewDialog preview(&printer);
connect(&preview,
SIGNAL(paintRequested
(QPrinter *)),
this,
SLOT(print
(QPrinter *)));
preview.setMinimumHeight(500);
preview.exec();
QPrinter printer(QPrinter::ScreenResolution);
printer.setPaperSize(QPrinter::A4);
printer.setFullPage(true);
QPrintPreviewDialog preview(&printer);
connect(&preview, SIGNAL(paintRequested(QPrinter *)), this, SLOT(print(QPrinter *)));
preview.setMinimumHeight(500);
preview.exec();
To copy to clipboard, switch view to plain text mode
And the print() slot contains this (among other layouting code):
...
painter.
setRenderHint(QPainter::Antialiasing);
int w = printer->pageRect().width();
int h = printer->pageRect().height();
QRect region
( 0,
0, w, h
);
QRectF diagramSize
(region.
left(),region.
top(),region.
width(), region.
height());
//scene is a QGraphicsScene
scene->render(&painter,diagramSize,scene->itemsBoundingRect());
...
QPainter painter( printer );
painter.setRenderHint(QPainter::Antialiasing);
int w = printer->pageRect().width();
int h = printer->pageRect().height();
QRect region( 0, 0, w, h );
QRectF diagramSize(region.left(),region.top(),region.width(), region.height());
//scene is a QGraphicsScene
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
Bookmarks