Hello to all.
I am trying to design a Qt Application for a DAQ System and I would like to have a TCanvas/TRootEmbeddedCanvas in my project using ROOT as plotter for my online display.
Imagine that my mainwindow consists of a QTabWidget, and a tab of this is called displayTab. What I would like to do is to import a TCanvas in this tab. During my testing phase, what I’m trying to achieve is when a QPushButton is clicked(), just draw a TF1 in a canvas which has as parent the displayTab.
So far, I have edited my .pro file to include these lines
[code][…]
include("$(ROOTSYS)/include/rootcint.pri")
[…]
win32:CONFIG(release, debug|release): LIBS += -L/home/nick/root/lib/release/ -lGpad -lCint -lCore -lGraf -lGraf3d -lHist -lGui -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lGQt
else:win32:CONFIG(debug, debug|release): LIBS += -L/home/nick/root/lib/debug/ -lGpad -lCint -lCore -lGraf -lGraf3d -lHist -lGui -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lGQt
else:symbian: LIBS += -lGpad -lCint -lCore -lGraf -lGraf3d -lHist -lGui -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lGQt
else:unix: LIBS += -L/home/nick/root/lib/ -lGpad -lCint -lCore -lGraf -lGraf3d -lHist -lGui -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lGQt
INCLUDEPATH += /home/nick/root/include
DEPENDPATH += /home/nick/root/include[/code]
With these lines I can link the ROOT libraries and they seem to work, as for example I use a TEnv class instance and works like a charm.
I include TQtWidget.h header in the class that is going to draw the function and the diplay() function that is going to be called when the QPushButton is clicked() looks like this
void Classs::display(){
TQtWidget *tqt = new TQtWidget(m_ui->displayTab); // trying to convert a QWidget to TQtWidget
TCanvas *c1 = new TCanvas(tqt); // to my knowledge this should place a TCanvas to tqt (a.k.a. displayTab)
c1->cd();
TF1 *f1 = new TF1("f1", "1/x", 0,10);
f1->Draw();
}
It compiles, links and builds perfectly but during execution when the QPushButton is clicked a new TCanvas pops up with the function plotted.
I also tried using TRootEmbeddedCanvas, but as its constructor asks for a TGWindow parent, I could not create one and bind it to the displayTab. Finally, the solution of promotion of the QWidget to TQtWidget (or even TGWindow) didn’t work, as I’m using QtCreator and an error comes up concerning its built-in header file
../../root/include/TGWindow.h: In member function ‘void Ui_Interface::setupUi(QMainWindow*)’:
../../root/include/TGWindow.h:49:4: error: ‘TGWindow::TGWindow(Window_t)’ is protected
ui_interface.h:170:47: error: within this context
ui_interface.h:170:47: error: invalid conversion from ‘QWidget*’ to ‘Window_t’
ui_interface.h:170:47: error: initializing argument 1 of ‘TGWindow::TGWindow(Window_t)’
ui_interface.h:171:23: error: ‘class TGWindow’ has no member named ‘setObjectName’
ui_interface.h:172:23: error: ‘class TGWindow’ has no member named ‘setGeometry’
Is there any way to bind the canvas to the main window?
I would like to thank you in advance for any input you could provide me with.
P.S. I’m using ROOT 5.30, Qt 4.7.2 and I’m under UNIX environment.