title: How to use QPrinter and QPrintPreviewDialog
body: <p>I want to preview, and then print, a report through a printer using PyQt. I tried the following code :</p>
  
  <pre><code>printer = QtGui.QPrinter()
  doc  = QtGui.QTextDocument("testing")
  dialog = QtGui.QPrintDialog(printer)
  dialog.setModal(True)
  dialog.setWindowTitle("printerrr")
  pdialog = QtGui.QPrintPreviewDialog(printer)
  pdialog.setWindowFlags(QtCore.Qt.Window)
  pdialog.exec_()
  </code></pre>
  
  <p>How I can preview my report then print it?</p>