How to save the content of a qTableWidget in a MRB file?


I would like to know how to save the content of a qTableWidget in a MRB file?

For research I am doing, I have written a scripted loadable module which enables me to do all my measurements and save everything information I need from one subject in a single MRB file. This includes pre operative segmentation of perforator vessels, segmentation of the bone, and the measurments I conduct in the operation theatre.

Since I am also required to save qualitative data, I have created a qTableWidget in a slicer module extension in which I can save the required data. However, when I save the whole scene in an MRB file, the data in the table is lost.

Is there any way to save this, or is there a better method I could use?

Instead of a qTableWidget, which is purely GUI, you can create a vtkMRMLTableNode which is part of the scene (saved/restored with the MRB). You can display these natively with table (or plot) views in the Slicer interface (e.g. Script repository — 3D Slicer documentation).


You can also display the MRML table in your module widget using a qMRMLTableView. You can simply drag-and-drop this view into your module GUI in Qt designer and set the MRML scene and the table node you want to view/edit in it.

1 Like

Thank you gentleman! That is exactly what I wanted :slight_smile: