From $ROOTSYS/tutorials/gui/QtPrintDialog.C

// @(#)root/qt:$Name:  $:$Id$
// Author: Valeri Fine   23/03/2006
#ifndef __CINT__
#  include <QPrintDialog>
#  include <QPrinter>
#  include <QPainter>
#  include <QPixmap>
#  include <TCanvas.h>
#  include <TGQt.h>
#endif
void  QtPrintDialog(TVirtualPad *pad = 0) {
  //
  // This is a small ROOT macro to use Qt 3.3 class: begin_html <a href="http://doc.trolltech.com/3.3/qprinter.html">QPrinter</a> end_html
  // to setup the printer via Qt "setup printer dialog"
  // See: begin_html <a href="http://doc.trolltech.com/3.3/qprinter.html#setup">Printer setup dialog box</a>  end_html
  // and print out the ROOT TCanvas object either via the "can" pointer provided or the current one.
  //
  // To use, invoke ACLiC from the ROOT prompt:
  // root [] .x QtPrintDialog.C++
  //
  // To use it with no ACLiC, omit the trailing "++"
  // root [] .x QtPrintDialog.C
  //
  //
  // The full list of the Qt classes available from Cint is defined by
  // begin_html <a href="http://root.bnl.gov/QtRoot/htmldoc/src/qtclasses.h.html">by $ROOTSYS/cint/lib/qtclasses.h</a> end_html
  //
  // All Qt classes can be used from ACLiC though.

#ifdef __CINT__
  // Load the qt cint dictionary.
  // One is recommended to do that at once somewhere.
  // For example from one's custom rootlogon.C script
  gSystem->Load("$ROOTSYS/cint/cint/include/qtcint");
#endif
  TVirtualPad *pd = pad;
  if (!pd) pd = TPad::Pad(); // ->GetCanvas();
  if (pd) {
    QPrinter p;
    // Open the Qt "Setup Printer" dialog to configure the "QPrinter p" object
    QPrintDialog printDialog(&p);
    if (printDialog.exec() == QDialog::Accepted) {
       Int_t id = pd->GetPixmapID();
       QPixmap *pix = (QPixmap *)(TGQt::iwid(id));
       QPainter pnt(&p);
       pnt.drawPixmap(0,0,*pix);
    }
  } else {
     printf(" No TCanvas has been selected yet! \n");
  }
}

 QtPrintDialog.C:1
 QtPrintDialog.C:2
 QtPrintDialog.C:3
 QtPrintDialog.C:4
 QtPrintDialog.C:5
 QtPrintDialog.C:6
 QtPrintDialog.C:7
 QtPrintDialog.C:8
 QtPrintDialog.C:9
 QtPrintDialog.C:10
 QtPrintDialog.C:11
 QtPrintDialog.C:12
 QtPrintDialog.C:13
 QtPrintDialog.C:14
 QtPrintDialog.C:15
 QtPrintDialog.C:16
 QtPrintDialog.C:17
 QtPrintDialog.C:18
 QtPrintDialog.C:19
 QtPrintDialog.C:20
 QtPrintDialog.C:21
 QtPrintDialog.C:22
 QtPrintDialog.C:23
 QtPrintDialog.C:24
 QtPrintDialog.C:25
 QtPrintDialog.C:26
 QtPrintDialog.C:27
 QtPrintDialog.C:28
 QtPrintDialog.C:29
 QtPrintDialog.C:30
 QtPrintDialog.C:31
 QtPrintDialog.C:32
 QtPrintDialog.C:33
 QtPrintDialog.C:34
 QtPrintDialog.C:35
 QtPrintDialog.C:36
 QtPrintDialog.C:37
 QtPrintDialog.C:38
 QtPrintDialog.C:39
 QtPrintDialog.C:40
 QtPrintDialog.C:41
 QtPrintDialog.C:42
 QtPrintDialog.C:43
 QtPrintDialog.C:44
 QtPrintDialog.C:45
 QtPrintDialog.C:46
 QtPrintDialog.C:47
 QtPrintDialog.C:48
 QtPrintDialog.C:49
 QtPrintDialog.C:50
 QtPrintDialog.C:51
 QtPrintDialog.C:52
 QtPrintDialog.C:53