Results 1 to 2 of 2

Thread: 1:1 printing with QGraphicsView

  1. #1
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question 1:1 printing with QGraphicsView

    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:

    Qt Code:
    1. void GraphicsViewer::Print()
    2. {
    3. QPrinter printer( QPrinter::ScreenResolution );
    4. printer.setPageSize( QPrinter::Letter );
    5. printer.setOrientation( QPrinter::Portrait );
    6.  
    7. QPrintDialog dialog( &printer, this );
    8. if( dialog.exec() == QDialog::Accepted )
    9. {
    10. QPainter painter(&printer);
    11. GetGraphicsView()->scene()->render( &painter );
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 1:1 printing with QGraphicsView

    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.

Similar Threads

  1. QGraphicsScene and QGraphicsView
    By sabeesh in forum Qt Programming
    Replies: 7
    Last Post: 1st August 2007, 06:59
  2. QGraphicsView
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2007, 08:00
  3. Printing problem in windows
    By joseph in forum Qt Programming
    Replies: 6
    Last Post: 12th July 2007, 08:04
  4. Speed, transparency, and drop issues with QGraphicsView
    By jefferai in forum Qt Programming
    Replies: 16
    Last Post: 30th June 2007, 16:14
  5. Replies: 0
    Last Post: 28th June 2006, 20:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.