0
votes

I am working on an application that uses the Qt library on Windows.

I want the user to be able to configure the printer where the application should print. So my main menu will contain the following entries:

  • Printer Setup...: should show a dialog where the user can select and configure the printer
  • Print...: perform the actual print

In other, non-Qt, applications I used the Windows function PrintDlg with the flag PD_PRINTSETUP. This showed the following dialog, which is exactly what I want: enter image description here

However, the Qt function QPrintDialog uses the more recent PrintDlgEx function, which looks like this: enter image description here

This dialog seems to be intended for actual printing. Not for setting and configuring the printer.

  • It shows a Print button instead of simply OK.
  • It contains a 'Page Range' group box, which isn't really useful when setting up the printer configuration.

The QPageSetupDialog isn't really useful in my case either. It looks like this: enter image description here So this only makes it useful for setting the page size, the orientation and the margins.

Is there a clean way in Qt to get a decent printer configuration dialog?

If I can't find a clean way, I need to revert to the native Windows PrintDlg function, which means patching or duplicating the code in the Qt source qprintdialog_win.cpp.

1
have your tried the QPrintPreviewWidget?Vinicius Kamakura
I don't want to preview my print output. I just want to let the user select the and configure printer, without printing, so I can save the selected printer and its configuration in the configuration file of my application, or in my data file.Patrick
I'm just guessing here, but can you disable the Print button via some option? You can then only leave the Apply and Cancel buttons, maybe then you get what you want. I have interest in all the Qt related stuff even though I'm not printing anything atm :)Vinicius Kamakura
No, that doesn't seem to be possible.Patrick

1 Answers

1
votes

I'm afraid you'll need to revert to the native Windows PrintDlg function as Qt4 correctly uses the PageSetupDlg function for page setup.

In Windows, although the PrintDlg can use the PD_PRINTSETUP to make the dialog act as Print Setup Dialog box, that functionality is not reccomended for new applications.

Quoting from MS: "new applications should not use PrintDlg for this purpose. The Print Setup dialog box has been superseded by the Page Setup dialog box created by the PageSetupDlg function."