PDA

View Full Version : 1:1 printing with QGraphicsView



joshlareau
25th September 2007, 15:34
I have a QGraphicsView application that handles drawing lines between nodes. The nodes represent holes that will be drilled into a test fixture and the lines are wires between the nodes. I am trying to print out just the nodes, so that the printout can be affixed over the actual test fixture.

The problem I'm having is that when I run the following code:



void GraphicsViewer::Print()
{
QPrinter printer( QPrinter::ScreenResolution );
printer.setPageSize( QPrinter::Letter );
printer.setOrientation( QPrinter::Portrait );

QPrintDialog dialog( &printer, this );
if( dialog.exec() == QDialog::Accepted )
{
QPainter painter(&printer);
GetGraphicsView()->scene()->render( &painter );
}
}


The printout is scaled to fit the page because of the aspectRatioMode argument to the render function. How do I tell the render function that I do not want to scale to fit the page, and I want a true what you see is what you get representation of my QGraphicsScene on the paper?

wysota
25th September 2007, 16:34
Well... A short answer is that in your graphics view you should use coordinates (lengths) that match those you want to receive on the printout (like milimetres). And then you should probably use high resolution printing when creating QPrinter.