Results 1 to 2 of 2

Thread: QPrinter on QGraphicsScene Border Problem

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QPrinter on QGraphicsScene Border Problem

    How i can leave QPrinter border / margin ? my QGraphicsScene is exact A4...
    the grey part is the paper & white is margin to write...
    i wand fill exact the grey part on A4..

    Now here .. QPrinter display a default border i suppose...

    Qt Code:
    1. /* XSL-FO -editor base widget */
    2. /* http://www.zvon.org/xxl/xslfoReference/Output/index.html
    3. <fo:simple-page-master margin-right="5pt" margin-left="5pt" margin-bottom="22pt" margin-top="22pt" page-width="21cm" page-height="29.7cm" master-name="first">
    4. <fo:region-body/>
    5. </fo:simple-page-master>
    6. */
    7. void DisplayScene::MakefilePrintPdf()
    8. {
    9. QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",QString(setter.value("LastDir").toString()), "*.pdf");
    10. if (fileName.size() > 1) {
    11. QString UserlastDirOpen = fileName.left(fileName.lastIndexOf("/"))+"/";
    12. setter.setValue("LastDir",UserlastDirOpen);
    13. QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    14. QPrinter printer(QPrinter::HighResolution);
    15. printer.setOutputFormat(QPrinter::PdfFormat);
    16. if (!fileName.endsWith(".pdf")) {
    17. fileName = fileName+".pdf";
    18. }
    19. printer.setOutputFileName(fileName);
    20. printer.setPageSize ( QPrinter::A4 );
    21. QPainter painter(&printer);
    22. scene->render(&painter); /* scene QGraphicsScene */
    23. if (is_file(fileName)) {
    24. QApplication::restoreOverrideCursor();
    25. /* disply pdf if exist! */
    26. OpenDesktop(QUrl(fileName));
    27. }
    28. }
    29. QApplication::restoreOverrideCursor();
    30. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    Attached Files Attached Files

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

    Default Re: QPrinter on QGraphicsScene Border Problem

    Change the viewport of the painter to the size of printable area.

Similar Threads

  1. problem with mouse release on the border, help me!
    By dungsivn in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 09:16

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.