ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QtPrintDialog.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_gui
3 /// This is a small ROOT macro to use Qt 3.3 class: [QPrinter](https://doc.qt.io/archives/3.3/qprinter.html)
4 /// to setup the printer via Qt "setup printer dialog"
5 /// See: [Printer setup dialog box](https://doc.qt.io/archives/3.3/qprinter.html#setup)
6 /// and print out the ROOT TCanvas object either via the "can" pointer provided or the current one.
7 ///
8 /// To use, invoke ACLiC from the ROOT prompt:
9 /// ~~~
10 /// root [] .x QtPrintDialog.C++
11 /// ~~~
12 ///
13 /// To use it with no ACLiC, omit the trailing "++"
14 /// ~~~
15 /// root [] .x QtPrintDialog.C
16 /// ~~~
17 ///
18 /// The full list of the Qt classes available from Cint is defined by
19 /// [by $ROOTSYS/cint/lib/qtclasses.h](http://root.bnl.gov/QtRoot/htmldoc/src/qtclasses.h.html)
20 ///
21 /// All Qt classes can be used from ACLiC though.
22 ///
23 /// \macro_code
24 ///
25 /// \author Valeri Fine 23/03/2006
26 
27 #ifndef __CINT__
28 # include <QPrintDialog>
29 # include <QPrinter>
30 # include <QPainter>
31 # include <QPixmap>
32 # include <TCanvas.h>
33 # include <TGQt.h>
34 #endif
35 void QtPrintDialog(TVirtualPad *pad = 0) {
36 
37 #ifdef __CINT__
38  // Load the qt cint dictionary.
39  // One is recommended to do that at once somewhere.
40  // For example from one's custom rootlogon.C script
41  gSystem->Load("$ROOTSYS/cint/cint/include/qtcint");
42 #endif
43  TVirtualPad *pd = pad;
44  if (!pd) pd = TPad::Pad(); // ->GetCanvas();
45  if (pd) {
46  QPrinter p;
47  // Open the Qt "Setup Printer" dialog to configure the "QPrinter p" object
48  QPrintDialog printDialog(&p);
49  if (printDialog.exec() == QDialog::Accepted) {
50  Int_t id = pd->GetPixmapID();
51  QPixmap *pix = (QPixmap *)(TGQt::iwid(id));
52  QPainter pnt(&p);
53  pnt.drawPixmap(0,0,*pix);
54  }
55  } else {
56  printf(" No TCanvas has been selected yet! \n");
57  }
58 }
59 
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1766
int Int_t
Definition: RtypesCore.h:41
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Definition: TVirtualPad.cxx:30
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
virtual Int_t GetPixmapID() const =0
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
tuple pad
Definition: first.py:38
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)