0

Is it possible to extend the Qt print dialog (QPrintDialog) with additional UI elements, as it can be done in MFC via the PD_ENABLEPRINTTEMPLATE macro? See this link.

I didn't find anything in the Qt documentation about this.

It seems that Qt shows the native print dialog on Windows, which probably makes it even more difficult?

Fabian
  • 1,824
  • 3
  • 19
  • 35
  • Typed an answer too fast without properly reading the question ;) It is possible with the QFileDialog by subclassing QFileDialog and retrieving the Layout of the dialog to add additional layouts, but I am not sure about QPrintDialog - the documentation says "On Windows, the native dialog is used" – Andreas Fester Oct 04 '12 at 10:14
  • Updated my answer, hope it is correct now :) – Andreas Fester Oct 04 '12 at 10:59

1 Answers1

3

That is not possible in a platform neutral way. For QFileDialog, you can subclass it (in which case Qt automatically uses the non-native dialog on all platforms) and add UI elements to the layout. On X11, this also works for QPrintDialog, but on WIN32 there is a completely separate source code (src/gui/dialogs/qprintdialog_win.cpp) which calls the PrintDlgEx Windows API function. There exists no platform neutral implementation of the QPrintDialog which you can use on Windows/MacOS.

I would think about designing the UI in such a way that the "print" action of the application shows a dialog with all application specific settings, probably including a preview, and which contains a button to open the QPrintDialog to choose the printer and set any printer specific properties.

Andreas Fester
  • 36,091
  • 7
  • 95
  • 123
  • +1 for how you suggested to design the *custom print dialog*, opening the native print dialog via a button. This sounds very nice ;) – leemes Oct 04 '12 at 12:32
  • Hi Andreas. If there is no way to customize the dialog then this indeed sounds like the best way to go. Thanks! – Fabian Oct 04 '12 at 19:13