May 2019
Intermediate to advanced
542 pages
13h 37m
English
Before we can physically print a document, we have to first print QTextDocument to the QPrinter object. This is done by passing the printer object to the document's print() method.
We'll create the following method to do that for us:
def _print_document(self): self.preview.document().print(self.printer)
Note that this doesn't actually cause your printing device to start putting ink on the page – it just loads the document into the QPrinter object.
To actually print it to paper, a printer dialog is needed; so, add the following method to MainView:
def print_dialog(self): self._print_document() dialog = qtps.QPrintDialog(self.printer, self) dialog.exec() self._update_preview_size()
In this method, we first call our internal ...
Read now
Unlock full access