Win11 python pyside6 qprinter instantiation attetion
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 | printer_info_s = QPrinterInfo.availablePrinters() |
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