Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ExampleMain.cpp
Go to the documentation of this file.
1// Author: Sergey Linev, GSI 13/01/2021
2
3/*************************************************************************
4 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#include <QTimer>
12#include <QApplication>
13
14#include "TApplication.h"
15#include "TSystem.h"
16
17#include "ExampleWidget.h"
18
19#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
20#include <QtWebEngine>
21#endif
22
23int main(int argc, char **argv)
24{
25#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
26 // must be called before creating QApplication, from Qt 5.13, not needed for Qt6
27 QtWebEngine::initialize();
28#endif
29
30 argc = 1; // hide all additional parameters from ROOT and Qt
31 TApplication app("uno", &argc, argv); // ROOT application
32
33 char* argv2[3];
34 argv2[0] = argv[0];
35 argv2[1] = 0;
36
37 QApplication myapp(argc, argv2); // Qt application
38
39 // let run ROOT event loop
40 QTimer timer;
41 QObject::connect( &timer, &QTimer::timeout, []() { gSystem->ProcessEvents(); });
42 timer.setSingleShot(false);
43 timer.start(4);
44
45 // top widget
46 ExampleWidget* widget = new ExampleWidget();
47
48 widget->setWindowTitle(QString("QtWeb application, build with qt ") + QT_VERSION_STR);
49
50 QObject::connect(&myapp, &QApplication::lastWindowClosed, &myapp, &QApplication::quit);
51
52 widget->show();
53
54 int res = myapp.exec();
55 return res;
56}
int main()
Definition Prototype.cxx:12
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:416