Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top