May 2019
Intermediate to advanced
542 pages
13h 37m
English
Readers outside the United States almost certainly groaned when we hard-coded the dimensions of our document to 8.5×11, but never fear—we're going to make some changes that will allow us to set the size based on a user's selection of document sizes.
In the InvoiceView class, create the following new method, set_page_size(), to set the page size:
def set_page_size(self, qrect): self.doc_width = qrect.width() self.doc_height = qrect.height() self.setFixedSize(qtc.QSize(self.doc_width, self.doc_height)) self.document().setPageSize( qtc.QSizeF(self.doc_width, self.doc_height))
This method will receive a QRect object, from which it will extract width and height values to update the document's settings, ...
Read now
Unlock full access