I’m trying to connect a callback in the widget class of my scripted module with a custom event of the logic class. My first attempt has been with the Qt signal/slot system, much like in this post.
My code looks like so:
class MyModuleWidget(ScriptedLoadableModuleWidget, VTKObservationMixin): def setup(self): ... self.logic.moved.connect(self.onPtrMoved) def onPtrMoved(self): # do something class MyModuleLogic(ScriptedLoadableModuleLogic): def __init__(self): ... self.moved = qt.Signal() @vtk.calldata_type(vtk.VTK_OBJECT) def someOtherCallback(self, caller, event=None, calldata=None): self.moved.emit()
When someOtherCallback is called, the signal is allegedly emitted and then Slicer crashes.
I would like to know why it’s not working given that the signal is emitted from its own class (which is better as pointed out here) and how to fix it. Also, I’m not restricted to using Qt for this and apparently resorting to a vtk custom event and an observer would be a better way (as suggested here) but I couldn’t find any example in Python.
Any help would be appreciated