7 #if QT_VERSION >= 0x40000
10 #include "q3toolbar.h"
11 #include "q3filedialog.h"
12 #include "q3strlist.h"
13 #include "q3popupmenu.h"
14 #include "q3intdict.h"
16 #include "q3toolbar.h"
17 #include "qnamespace.h"
18 #include "q3filedialog.h"
19 #include "q3whatsthis.h"
20 #include "Q3MimeSourceFactory"
22 #include "qfiledialog.h"
24 #include "qpopupmenu.h"
28 #include "qnamespace.h"
29 #include "qfiledialog.h"
30 #include "qwhatsthis.h"
44 #include "qtoolbutton.h"
49 #include "qcolordialog.h"
52 #include "qpushbutton.h"
56 #include "qapplication.h"
59 #include "qtoolbutton.h"
62 #include "qstatusbar.h"
63 #include "qmessagebox.h"
68 #include "filesave.xpm"
69 #include "fileopen.xpm"
70 #include "fileprint.xpm"
71 #include "qtbuttonsupdate.xpm"
72 #include "qtbuttonsclear.xpm"
98 "Click this button to open a <em>new file</em>. <br><br>"
99 "You can also select the <b>Open command</b> from the File menu.";
100 const char *
fileSaveText =
"Click this button to save the file you are "
101 "editing. You will be prompted for a file name.\n\n"
102 "You can also select the Save command from the File menu.\n\n"
103 "Note that implementing this function is left as an exercise for the reader.";
106 "You can also select the Print command from the File menu.";
117 :
Q3MainWindow( 0,
"example application main window", Qt::WDestructiveClose )
123 Q3Action *fileNewAction =
new Q3Action(
"New",
"&New", Qt::CTRL+Qt::Key_N,
this,
"new" );
125 connect( fileNewAction, SIGNAL( activated() ) ,
this, SLOT(
newDoc() ) );
127 Q3Action *fileOpenAction =
new Q3Action(
"Open File", QPixmap( fileopen ),
"&Open", Qt::CTRL+Qt::Key_O,
this,
"open" );
128 connect( fileOpenAction, SIGNAL( activated() ) ,
this, SLOT(
load() ) );
129 Q3MimeSourceFactory::defaultFactory()->setPixmap(
"fileopen", QPixmap( fileopen ) );
132 Q3Action *fileSaveAction =
new Q3Action(
"Save File", QPixmap( filesave ),
"&Save", Qt::CTRL+Qt::Key_S,
this,
"save" );
133 connect( fileSaveAction, SIGNAL( activated() ) ,
this, SLOT(
save() ) );
136 Q3Action *fileSaveAsAction =
new Q3Action(
"Save File As",
"Save &as", 0,
this,
"save as" );
137 connect( fileSaveAsAction, SIGNAL( activated() ) ,
this, SLOT(
saveAs() ) );
140 Q3Action *filePrintAction =
new Q3Action(
"Print File", QPixmap( fileprint ),
"&Print", Qt::CTRL+Qt::Key_P,
this,
"print" );
141 connect( filePrintAction, SIGNAL( activated() ) ,
this, SLOT(
print() ) );
144 Q3Action *fileCloseAction =
new Q3Action(
"Close",
"&Close", Qt::CTRL+Qt::Key_W,
this,
"close" );
145 connect( fileCloseAction, SIGNAL( activated() ) ,
this, SLOT(
close() ) );
147 Q3Action *fileQuitAction =
new Q3Action(
"Quit",
"&Quit", Qt::CTRL+Qt::Key_Q,
this,
"quit" );
148 connect( fileQuitAction, SIGNAL( activated() ) , qApp, SLOT( quit() ) );
151 Q3Action *Update_histo =
new Q3Action(
"Update Histo",QPixmap(
"qtbuttonsupdate.xpm"),
"&Update", Qt::CTRL+Qt::Key_0,
this,
"update");
152 connect( Update_histo, SIGNAL( activated() ) ,
this, SLOT(
execute() ) );
153 Q3MimeSourceFactory::defaultFactory()->setPixmap(
"update", QPixmap(
"qtbuttonsupdate.xpm" ) );
156 Q3Action *
clear_histo =
new Q3Action(
"Clear Histo",QPixmap(
"qtbuttonsclear.xpm"),
"&Clear", Qt::CTRL+Qt::Key_0,
this,
"clear"); connect( clear_histo, SIGNAL( activated() ) ,
this, SLOT(
clear_histo() ) );
157 Q3MimeSourceFactory::defaultFactory()->setPixmap(
"clear", QPixmap(
"qtbuttonsclear.xpm" ) );
163 fileTools->setLabel( tr(
"File Operations" ) );
164 fileOpenAction->addTo( fileTools );
165 fileSaveAction->addTo( fileTools );
166 filePrintAction->addTo( fileTools );
167 Update_histo->addTo ( fileTools );
168 clear_histo->addTo ( fileTools );
169 (
void)Q3WhatsThis::whatsThisButton( fileTools );
173 menuBar()->insertItem(
"&File", file );
174 fileNewAction->addTo( file );
175 fileOpenAction->addTo( file );
176 fileSaveAction->addTo( file );
177 fileSaveAsAction->addTo( file );
178 file->insertSeparator();
179 filePrintAction->addTo( file );
180 file->insertSeparator();
181 fileCloseAction->addTo( file );
182 fileQuitAction->addTo( file );
187 menuBar()->insertSeparator();
188 menuBar()->insertItem(
"&Help", help );
189 help->insertItem(
"&About",
this, SLOT(
about()), Qt::Key_F1 );
190 help->insertItem(
"About &Qt",
this, SLOT(
aboutQt()) );
191 help->insertSeparator();
192 help->insertItem(
"What's &This",
this, SLOT(whatsThis()),
Qt::SHIFT+Qt::Key_F1 );
195 tab =
new QTabWidget(
this);
197 setCentralWidget(
tab );
204 win1->setCentralWidget(
aCanvas);
208 tab->addTab(win1,
"page1");
209 tab->addTab(win2,
"page2");
226 pad1 =
new TPad(
"pad1",
"The pad with the function",0.05,0.50,0.95,0.95,21);
231 pad1->GetFrame()->SetFillColor(42);
232 pad1->GetFrame()->SetBorderMode(-1);
233 pad1->GetFrame()->SetBorderSize(5);
235 histo=
new TH1F(
"hppx",
"Gaussian distribution",100,-4,4);
236 histo->SetFillColor(0);
240 pad2 =
new TPad(
"pad2",
"The pad with the histogram",0.05,0.05,0.95,0.45,21);
244 form1 =
new TFormula(
"form1",
"abs(sin(x)/x)");
245 sqroot =
new TF1(
"sqroot",
"x*gaus(0) + [3]*form1",0,10);
246 sqroot->SetParameters(10,4,1,20);
256 c1->SetFillColor(42);
257 c1->GetFrame()->SetFillColor(21);
258 c1->GetFrame()->SetBorderSize(12);
269 TGraph*
gr =
new TGraph(n,x,y);
272 gr->SetMarkerColor(4);
273 gr->SetMarkerStyle(21);
274 gr->SetTitle(
"a simple graph");
277 gr->GetHistogram()->SetXTitle(
"X title");
278 gr->GetHistogram()->SetYTitle(
"Y title");
286 qDebug(
" ~ApplicationWindow() \n");
298 gROOT->GetSelectedPad()->Modified();
299 gROOT->GetSelectedPad()->Update();
312 for (
Int_t i = 0; i < 25000; i++) {
316 if (i && (i%kUPDATE) == 0) {
317 if (i == kUPDATE)
histo->Draw(
"same");
340 statusBar()->message(
"Loading aborted", 2000 );
361 int testvar = QMessageBox::information( 0,
"Qt Application Example",
362 "Do you want to close QtRoot? "
363 "",
"Save",
"Cancel",
"Close",
382 qDebug(
"detecting fitpanel %x \n",fitpanel);
386 qDebug(
"detecting drawpanel %x \n",drawpanel);
396 QMessageBox::about(
this,
"Qt&ROOT Application Example",
397 "This example demonstrates simple use of "
398 "QMainWindow,\nQMenuBar and QToolBar.");
403 QMessageBox::aboutQt(
this,
"Qt Application Example" );
void aboutQt()
online help about this Qt based Application
void clear_histo()
Main slot to reinitialize the objects.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
void print()
print results in a specified format
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
void execute()
Main slot action upon ROOT classes.
const char * filePrintText
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
void about()
online help about Qt&Root Main Application
const char * fileOpenText
Main Qt&Root Application Window:
void save()
Saving results function:
void newDoc()
New incoming functionality documentation.
void closeEvent(QCloseEvent *ce)
R__EXTERN TRandom * gRandom
const char * fileSaveText
QMimeSourceFactory Q3MimeSourceFactory
Mother of all ROOT objects.
typedef void((*Func_t)())
void saveAs()
saving pictures, in different supported formats