Priority: P2: Important
Affects Version/s: 5.12.11, 5.15.0 RC2
Fix Version/s: None
Component/s: GUI: Printing
I have an application that uses QPrintDialog to select a printer. Most of the time, I can choose any printer I want, and the application prints fine. But I found a particular printer that (if it is the default printer) causes problems with OTHER printers-specifically, they have an empty page layout of 0x0. If the only problems were with the printer itself, I'd blame the print driver, but due to the behavior I found, I think it must be a Qt bug.
To reproduce the bug, I set my default printer to a HP LaserJet Enterprise 700 color MFP M775 (this is important. Several other printers do not seem to cause this problem). Then I print in the application, but choose a different printer and click print. If I instead click "Preferences," change nothing, but click OK, the bug does not occur. Presumably this is because the settings have been "saved" back to Qt and override the broken values coming from the default printer. However, it shouldn't be necessary to open preferences and change nothing-those defaults for the new printer should be loaded when you change printers. I'm not sure what Windows exposes to Qt in terms of "unchanged" defaults, but other Windows applications seem to work ok, so there must be a solution, I'm thinking.
Below is the code that has problems (along with a workaround).
After the printer is created, I checked the QPrinterInfo for the default printer (HP M775). Note the default resolution=-1, which I suspect is the source of the problem. However, the pagelayout is entirely fine.
After I use the print dialog to choose a different printer (Bluebeam PDF printer here, but other printers have the same issue), printer info looks ok. Note the defaultResolution is set. But the pagelayout appears to just be a zeroed structure.
I can reproduce this issue 100% of the time, using the printer I mentioned above, and following the steps. Found the issue with 5.12, continues in 5.15.