regular
4th February 2014, 21:13
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:
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();
And the print() slot contains this (among other layouting code):
...
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.widt h(), region.height());
//scene is a QGraphicsScene
scene->render(&painter,diagramSize,scene->itemsBoundingRect());
Any ideas as to why it might be happening?
Thanks in advance
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:
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();
And the print() slot contains this (among other layouting code):
...
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.widt h(), region.height());
//scene is a QGraphicsScene
scene->render(&painter,diagramSize,scene->itemsBoundingRect());
Any ideas as to why it might be happening?
Thanks in advance