I have a DAQ application which makes some TH1D in Qt.
The filling and writing to file works.
I want to be able to monitor=plot=draw() the histograms during data acquisition.
I tried TRint but did not make it work yet.
I also tried just starting a QProcess to start a session with root, but I cannot make this work either.
Anyone have a working example of these or something else?
milles thanks.
nobody working on Interactive Root in Qt?
Hi,
You need to let ROOT handle events. To do so, create a timer calling gSystem->ProcessEvents();
Here is an example (using a QWidget, but you can adapt it to your needs)
//______________________________________________________________________________
QMainCanvas::QMainCanvas(QWidget *parent) : QWidget(parent)
{
// QMainCanvas constructor.
QVBoxLayout *l = new QVBoxLayout(this);
l->addWidget(canvas = new QRootCanvas(this));
l->addWidget(b = new QPushButton("&Draw Histogram", this));
connect(b, SIGNAL(clicked()), this, SLOT(clicked1()));
fRootTimer = new QTimer( this );
QObject::connect( fRootTimer, SIGNAL(timeout()), this, SLOT(handle_root_events()) );
fRootTimer->start( 20 );
}
//______________________________________________________________________________
void QMainCanvas::handle_root_events()
{
//call the inner loop of ROOT
gSystem->ProcessEvents();
}
This code is taken from the simple_canvas.tar.gz example of [url=https://root-forum.cern.ch/t/root-and-qt5/19073/1 post[/url]
See also How to Embed a TCanvas in External Applications?
Cheers, Bertrand.