// @(#)root/qt:$Name:  $:$Id: QtPrintDialog.C,v 1.4 2008/09/28 02:22:23 fine Exp $
// 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: 
QPrinter
  // to setup the printer via Qt "setup printer dialog"
  // See: 
Printer setup dialog box
  // 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
  // 
by $ROOTSYS/cint/lib/qtclasses.h
  //
  // 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 his/her 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");
  }
}


Last change: Wed Dec 17 10:55:40 2008
Last generated: 2008-12-17 10:55

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.