Notes on using QPrinter in Pyside6:

Pyside6.8 in Win11\Python3.12 needs to substitute parameters when instantiating QPrinter, otherwise the instantiation will have inexplicable bugs or be very slow and cannot be instantiated.

Found it while debugging

1
printer = QPrinter()

Sometimes it cannot be instantiated. Even if it can be instantiated, the program will take more than 20 seconds or even a minute to complete.

Solution:

1
2
3
printer_info_s = QPrinterInfo.availablePrinters()
printer_info = printer_info_s[0]
printer = QPrinter(printer_info)

List the printer list in the win system, and specify printer_info as the first one or the needed one, and then instantiate the printer