Reputation: 49
How do I set a 100% default value in QPrintPreviewDialog, Always a small page appears to me, I want to display it clearly automatically instead of choosing the number manually
Note. I did not find anything in this topic on this site
def handlePreview(self, InNum):
self.printer = QPrinter()
self.printer.setPageSize(QPrinter.A4)
self.printer.setOrientation(QPrinter.Portrait)
self.printer.setPageMargins(0.3, 0.3, 0.3, 0.3, QPrinter.Millimeter)
dialog = QPrintPreviewDialog(self.printer)
dialog.setWindowState(QtCore.Qt.WindowMaximized)
dialog.paintRequested.connect(lambda: self.preparationHtml(InNum))
dialog.exec()
Upvotes: 2
Views: 657
Reputation: 244003
You have to get the QComboBox and change the index so that 100% zoom is selected:
dialog = QPrintPreviewDialog(self.printer)
combobox = dialog.findChild(QComboBox)
index = combobox.findText("100%")
combobox.setCurrentIndex(index)
Upvotes: 4