Logo ROOT   6.10/09
Reference Guide
qtrootexample1.ui.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** ui.h extension file, included from the uic-generated form implementation.
3 **
4 ** If you wish to add, delete or rename slots use Qt Designer which will
5 ** update this file, preserving your code. Create an init() slot in place of
6 ** a constructor, and a destroy() slot in place of a destructor.
7 *****************************************************************************/
8 #include "TCanvas.h"
9 #include "TClass.h"
10 #include "TFile.h"
11 
12 #if QT_VERSION >= 0x40000
13 //Added by qt3to4:
14 #include <QPixmap>
15 #include <QMimeSource>
16 #include <Q3MimeSourceFactory>
17 #include <Q3ImageDrag>
18 #include <Q3ListViewItem>
19 typedef Q3ListViewItem QListViewItem;
20 typedef Q3DragObject QDragObject;
21 typedef Q3TextDrag QTextDrag;
22 typedef Q3ImageDrag QImageDrag;
23 typedef Q3MimeSourceFactory QMimeSourceFactory;
24 #endif
25 
26 static QPixmap uic_load_pixmap( const QString &name )
27 {
28  const QMimeSource *m = QMimeSourceFactory::defaultFactory()->data( name );
29  if ( !m )
30  return QPixmap();
31  QPixmap pix;
32  QImageDrag::decode( m, pix );
33  return pix;
34 }
35 
37 {
38  TKey *key;
39  TFile *fxDiskFile;
40 
41  (TQRootCanvas1->GetCanvas())->Divide(2,2);
42  fxDiskFile = new TFile("test.root");
43  TIter next(fxDiskFile->GetListOfKeys());
44  while ((key = (TKey*) next())) {
45  AddItemToListView1(key->ReadObj());
46  }
47 }
48 
49 void qtrootexample1::destroy()
50 {
51 
52 }
53 
54 void qtrootexample1::ListView1_mouseButtonPressed( int, QListViewItem *SelectedItem, const QPoint &, int )
55 {
56  if (SelectedItem!=0) {
57  QDragObject *d = new QTextDrag(SelectedItem->text(0),ListView1);
58  d->dragCopy();
59  }
60 }
61 
62 void qtrootexample1::AddItemToListView1(TObject *Key)
63 {
64  if( Key->IsA()->InheritsFrom("TH2") ) {
65  QListViewItem * item1 = new QListViewItem(ListView1, Key->GetName() ,"TH2");
66  item1->setPixmap( 0, uic_load_pixmap( "h2_t.png" ) );
67  }
68  else if (Key->IsA()->InheritsFrom("TH1")) {
69  QListViewItem * item1 = new QListViewItem(ListView1, Key->GetName(),"TH1");
70  item1->setPixmap( 0, uic_load_pixmap( "h1_t.png" ) );
71  }
72 }
73 
static QPixmap uic_load_pixmap(const QString &name)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:436
TMarker * m
Definition: textangle.C:8
#define decode(ptr, otri)
Definition: triangle.c:912
static Int_t init()
QMimeSourceFactory Q3MimeSourceFactory
Definition: qtroot.cpp:37
Mother of all ROOT objects.
Definition: TObject.h:37
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition: TKey.cxx:730
virtual TList * GetListOfKeys() const
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:364