I’m looking for a way to detect when the scroll bar at the top of a view moves, or when the slice view changes. This can be done by detecting when the scroll wheel moves or when arrow keys are used, but I’d like to be able to detect the event itself. Is there a signal like that that can initiate a function when detected?
The suggested way is add an observer to the vtkMRMLSlliceNode corresponding to the view, but this won’t tell you how (mouse vs keyboard) the slice offset was modified, just that it did move. What’s your use case?
Yes my intended use is for just to see it was modified. Thanks for pointing me in the right direction!
Just wanted to confirm, is the observer method doable in C++ or just Python? I’m looking into C++ observer methods and it doesn’t seem to be able to be used for MRMLSliceNodes or MRMLScenes.
All Slicer features are available in both C++ and Python. In Slicer source code there are many examples for adding observers: search for AddObserver
if you are interested in adding observer from VTK classes, and search for qvtkReconnect
if you want to add observer from Qt classes.