I’ve searched and tried for several hours now but I can’t seem to figure this out. I use vtkMRMLTableNode for the table and qMRMLTableView for the GUI. How can I add an observer to the table that reacts on adding/modifying values in the cells. The only thing I found is ReferenceModifiedEvent in the vtkMRMLTableViewNode, but I couldn’t get that one to work.
Also, another question I had regarding tables are column types. I set the type of one of my columns to 1 (which as I understand it is a bool) but I don’t know how to change the cell values in the code now (SetCellText returns errors)
I hope you can understand my problem and thanks in advance for any help!
What you described should work. Could you send a link to your source code?
This is the code I use for the table
It seems that you try to create a point list widget. There is already such widget, with lots of features and configuration options: qSlicerSimpleMarkupsWidget.
# Create a markup fiducial list
# Create a list widget
fidListWidget.jumpToSliceEnabled = True
In your code the main issue was the you’ve observed the wrong event. This will work:
# Create table node
tableNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTableNode")
# Table view
# Observe modifications
def tableModified(caller, event):
observerTag = tableNode.AddObserver(vtk.vtkCommand.ModifiedEvent, tableModified)
Oh wow, I didn’t know there was something like that already. Thanks a lot! I will probably implement it later but for now I’ll try to get a better understanding first.
On a side node: Is it possible to get the row id that was modified via calldata or a similar function to slicer.clickedMarkupIndex? vtk.VTK_INT seems to crash slicer when calling the tableModified function.
Thank you very much - I ended up using the widget you suggested and everything is working fine now