[PyQt] QPrintDialog (pyqt4)

Russell Valentine russ at coldstonelabs.org
Wed Feb 17 06:20:23 GMT 2010


jaybstory wrote:
> Hello,
> 
> I am trying to print my gui, however I am having trouble. I have a button
> with a signal as clicked and slot as printd(which is my function that I am
> calling QPrintDialog. In printd, I have this code:
> 
> [CODE]
> def printd(self):
>            pd = QtGui.QPrintDialog(self)
>            pd.exec_()
> [/CODE]
> 
> Which successfully opens the popup window for printing items. However, when
> i click print, nothing ends up printing. I'm not sure what I am doing wrong
> here. Any suggestions? Thank you in advance.
> 
> NOTE: this is for help in PyQt4.

QPrintDialog is just a dialog, it just allows the user to set settings 
for printer. You still need to tell it what to print. Using QPrinter or 
something as a print device or some other method.

http://doc.trolltech.com/4.6/printing.html

If you actually want to print the widgets you can render the widget on 
the QPrinter device.


More information about the PyQt mailing list