0

I want to print the entire scroll area of the GUI. Currently I am only printing a screenshot of the visible portion of the GUI. Furthermore, none of the printer settings I am setting are being utilized, instead the default printer settings are used. See below for code sample and GUI. Thanks.

def printform(self):
    dialog = QtPrintSupport.QPrintDialog()
    if dialog.exec_() == QtWidgets.QDialog.Accepted:
        # Create printer
        printer = QtPrintSupport.QPrinter()
        printer.setprintrange = printer.AllPages
        printer.setPageSize = printer.Letter
        printer.setOrientation = printer.Landscape
        # Create painter
        painter = QtGui.QPainter()
        # Start painter
        painter.begin(printer)
        # Grab a widget you want to print, self.grab() for entire screen
        screen = self.grab()           
        # Draw grabbed pixmap
        painter.drawPixmap(10, 10, screen)
        # End painting
        painter.end()

enter image description here

NLhere
  • 15
  • 3
  • Just to get that clear, you want to print on an actual paper printer the GUI as it is, with text fields, etc. ? – Joe Apr 28 '20 at 05:46
  • https://stackoverflow.com/questions/9169329/screenshot-of-a-qt-application-from-inside-the-application – Joe Apr 28 '20 at 05:50
  • Is this supposed to be the "real" printing solution when someone is using the application later? – Joe Apr 28 '20 at 05:51
  • https://stackoverflow.com/questions/15738165/grabwidget-to-grab-the-complete-view-even-if-it-is-zoomed-in – Joe Apr 28 '20 at 05:52
  • https://doc.qt.io/qt-5/qtprintsupport-index.html and https://doc.qt.io/qt-5/qtprintsupport-index.html#printing-widgets – Joe Apr 28 '20 at 05:58
  • @Joe Yes I want to print the GUI on actual paper as it is, with all fields. – NLhere Apr 28 '20 at 09:56

0 Answers0