QPrintPreviewDialog 100% Zoom

590 Views Asked by At

enter image description here

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()
1

There are 1 best solutions below

2
On

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)