GSI Object Oriented Online Offline (Go4)  GO4-6.1.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ExampleWidget.cpp
Go to the documentation of this file.
1 // $Id: ExampleWidget.cpp 2978 2021-01-07 13:23:15Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "ExampleWidget.h"
15 
16 #include "QRootCanvas.h"
17 #include "TCanvas.h"
18 #include "TH1.h"
19 
20 #include <QMessageBox>
21 
22 ExampleWidget::ExampleWidget(QWidget *parent, const char* name) :
23  QWidget(parent)
24 {
25  setupUi(this);
26 
27  // TODO: viewpanel does not closed when press close button
28  setAttribute(Qt::WA_DeleteOnClose);
29 
30  setObjectName(name);
31 
32  fxQCanvas->setObjectName("example");
33  fxQCanvas->getCanvas()->SetName("example");
34  fxQCanvas->setEditorFrame(EditorFrame);
35  fxQCanvas->buildEditorWindow();
36 
37  fHisto = new TH1F("h1","title", 100, -5, 5);
38  fHisto->FillRandom("gaus", 10000);
39  fHisto->SetDirectory(nullptr);
40 
41  fxQCanvas->getCanvas()->cd();
42  fHisto->Draw("colz");
43 }
44 
46 {
47 }
48 
49 
51 {
52  QMessageBox::information(this,"QtRoot standalone example","Demo how QRootCanvas can be inserted into the QWidget");
53 }
54 
56 {
57  fxQCanvas->toggleEditor();
58 
59  // actiavte in ged some object
60  if (fxQCanvas->isEditorVisible()) {
61  fxQCanvas->activateEditor(fxQCanvas->getCanvas(), fHisto);
62  fxQCanvas->resizeEditor();
63  }
64 }
65 
66 void ExampleWidget::resizeEvent(QResizeEvent * e)
67 {
68  fxQCanvas->resizeEditor();
69 }
70 
72 {
73  // when widget closed, application automatically exit
74  close();
75 }
76 
77 
ExampleWidget(QWidget *parent=0, const char *name=0)
virtual ~ExampleWidget()
void InfoButton_clicked()
virtual void resizeEvent(QResizeEvent *e)
void ExitButton_clicked()
void EditorButton_clicked()