Issues with qtexample.py

Hi,

I’m trying to run the ROOT example qtexample.py, as I’m trying to build a GUI using PyQT to display ROOT histograms. I have compiled ROOT to include both PyROOT and PyQt, and have successfully run some code using each of these individually.

When I try to run qtexample.py however (which is the only example I can find that shows displaying a ROOT canvas in a PyQT GUI, either within ROOT or online), I get an error as follows:

Traceback (most recent call last):
  File "qtexample.py", line 51, in <module>
    QObject.connect(application, SIGNAL("lastWindowClosed()"),termAddress ,SLOT("Terminate()"))
RuntimeError: underlying C/C++ object has been deleted

I hav solved this by replacing:

with:

However, I then get a segmentation violation followed by this message:

Traceback (most recent call last):
  File "qtexample.py", line 52, in <module>
    w = window()
  File "qtexample.py", line 32, in __init__
    self.Canvas = ROOT.TQtWidget(sip.voidptr(self.Address).ascobject())
SystemError: problem in C++; program state has been reset

I have traced this issue to the PyROOT::TMethodHolder< T, M >::CallSafe function, which seems to be catching an underlying C++ exception, but I have not be able to get any further with this issue.

Note that I am using ROOT v5.34.14 and Qt 4.6.2 on Scientific Linux CERN SLC release 6.5 (Carbon). I have tried also on an ubuntu machine with the same result.

Can anyone help with this problem? Is ther an issue with my ROOT installation or general environment, or is there a problem with the example?

Additionally, if anyone knows of any other examples of displaying a ROOT canvas in a PyQt GUI then it would be very helpful!

Many thanks,
Tom

OK I seem to have solved this now, so for anyone else with the same problem (I’ve seen a few similar unanswered posts), the issue was as follows:

I think the issue was that libGQt.so was missing from the PYTHONPATH environment variable. The error was essentially equivalent to a linker “undefined reference to…” in C++, but it presents in PyRoot with the slightly confusing message in my original post.

There might also have been an issue with me not building qtcint using:

I had only used:

configure --enable-qt
make

This seemed to build some Qt elemetns in ROOT but not all. This information is missing from http://root.bnl.gov/QtRoot/How2Install4Unix.html, but can be found in ftp://root.cern.ch/root/doc/chapter27.pdf.

I’m having the same problem on my MacBook too.

[code] *** Break *** segmentation violation
Generating stack trace…
0x0000000125920614 in TQtWidget::TQtWidget(QWidget*, QFlagsQt::WindowType, bool) (in libGQt.6.06.06.so) + 260
0x00000001282eb160 in
0x00000001092dddd9 in FastCall(long, void*, void*, void*) (in libPyROOT.so) + 2617
0x00000001092de821 in Cppyy::CallConstructor(long, long, void*) (in libPyROOT.so) + 33
0x00000001092e59be in PyROOT::TConstructorExecutor::Execute(long, void*, PyROOT::TCallContext*) (in libPyROOT.so) + 78
0x00000001092ff036 in PyROOT::TMethodHolder::CallFast(void*, long, PyROOT::TCallContext*) (in libPyROOT.so) + 38
0x00000001092ff367 in PyROOT::TMethodHolder::CallSafe(void*, long, PyROOT::TCallContext*) (in libPyROOT.so) + 183
0x00000001092fed6e in PyROOT::TMethodHolder::Execute(void*, long, PyROOT::TCallContext*) (in libPyROOT.so) + 46
0x00000001092fbf9f in PyROOT::TConstructorHolder::Call(PyROOT::ObjectProxy*&, _object*, _object*, PyROOT::TCallContext*) (in libPyROOT.so) + 255
0x00000001092e74d6 in PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) (in libPyROOT.so) + 1542
0x000000010713eb43 in PyObject_Call (in Python) + 99
0x000000010719b15f in slot_tp_init (in Python) + 175
0x00000001071954cb in type_call (in Python) + 347
0x000000010713eb43 in PyObject_Call (in Python) + 99
0x00000001071dfe48 in PyEval_EvalFrameEx (in Python) + 27000
0x00000001071d91da in PyEval_EvalCodeEx (in Python) + 1690
0x0000000107164b4c in function_call (in Python) + 364
0x000000010713eb43 in PyObject_Call (in Python) + 99
0x000000010714bb96 in instancemethod_call (in Python) + 182
0x000000010713eb43 in PyObject_Call (in Python) + 99
0x000000010719b15f in slot_tp_init (in Python) + 175
0x00000001071954cb in type_call (in Python) + 347
0x000000010713eb43 in PyObject_Call (in Python) + 99
0x00000001071dfe48 in PyEval_EvalFrameEx (in Python) + 27000
0x00000001071d91da in PyEval_EvalCodeEx (in Python) + 1690
0x00000001071d8b36 in PyEval_EvalCode (in Python) + 54
0x00000001072069a4 in PyRun_FileExFlags (in Python) + 164
0x00000001072064da in PyRun_SimpleFileExFlags (in Python) + 698
0x000000010721c2a2 in Py_Main (in Python) + 3186
0x00007fff987275ad in start (in libdyld.dylib) + 1
0x0000000000000002 in
Traceback (most recent call last):
File “temp.py”, line 59, in
w = window()
File “temp.py”, line 40, in init
self.Canvas = ROOT.TQtWidget(sip.voidptr(self.Address).ascobject())
TypeError: none of the 2 overloaded methods succeeded. Full details:
TQtWidget::TQtWidget(QWidget* parent, const char* name, QFlagsQt::WindowType f = 0, bool embedded = true) =>
takes at least 2 arguments (1 given)
TQtWidget::TQtWidget(QWidget* parent = 0, QFlagsQt::WindowType f = 0, bool embedded = true) =>
problem in C++; program state has been reset

*** Break *** segmentation violation[/code]