Add an Addexec code to a Qt/Root Program

Hi,

i am currently writing a Qt program that needs to run an addExec code in the background of TCanvas. But I didn’t find how to implement this code in the main program, for now it’s an external .c file that is processed by CINT. Is it possible to add that function in the C++/Qt code?

Can you elaborate a little bit more? I see nothing Qt special as soon as AddExec is concern.
On the other hand the TQtWidget which is the Qt placeholder for TCanvas object emits a bunch of Qt signals those you connect to your Qt slots.

Hi,

I have currently a qt/root program which works properly, in this program I use a the AddExec method of the Tcanvas linking to the Tqtwidget to manage an interaction between the mouse and the data displayed. My AddExec use look like this: mycanvas->AddExec(“ex”,".x %directory_of_the_program_binaries%/mycode.c");

where mycode.c contains the function that handles the mouse events. My point is that I would like to not have to use an external code file and implement this function in my qt project, I know that technically it’s really weird because that function is not compiled but read by CINT, but if it’s possible I would like to do that.

I hope I clarified the situation, thanks.

I understand that you have no problem to use AddExec method. It works for you as designed. However, you would like to avoid it.

The TQtWidget object emits

RootEventProcessed(TObject *selected, unsigned int event, TCanvas *c); Qt signal.
Please check
root.cern.ch/root/html528/TQtWidget.html
and the original header file:
root.cern.ch/root/html528/src/TQtWidget.h.html
(ROOT html doc misses some header file components)
To do what you described you should be able to use the “RootEventProcessed(TObject *selected, unsigned int event, TCanvas *c);” Qt signal and Qt signal /slot communication to connect your pre-compiled Qt slots to the existing TQtWidget signal “RootEventProcessed(TObject *selected, unsigned int event, TCanvas *c”

Since TQtWidget is just the regular QWidget you can use the other approaches (for example you can add your own Qt event filters, you can put TQtWidget into the QWidget container , etc ) described by Qt documentation to customize your TCanvas management.

You may want download and install the “full” QtRoot from as described root.bnl.gov/QtRoot/How2Install4 … complement .

The distribution comes with qtExamples package containing the “hello word” level examples to demonstrate the various “QtRoot’ use cases including one you described.