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

**URL:** <https://discourse.slicer.org/t/how-to-save-the-content-of-a-qtablewidget-in-a-mrb-file/27480>\
**Category:** Development\
**Tags:** python, loadable-module\
**Created:** [January 26, 2023, 3:58pm UTC](https://discourse.slicer.org/t/how-to-save-the-content-of-a-qtablewidget-in-a-mrb-file/27480 "2023-01-26T15:58:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JessevdO](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@JessevdO](https://discourse.slicer.org/u/JessevdO)\
**Post date:** [January 26, 2023, 3:58pm UTC](https://discourse.slicer.org/t/how-to-save-the-content-of-a-qtablewidget-in-a-mrb-file/27480/1 "2023-01-26T15:58:39Z")

</div>

Hello,

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?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 26, 2023, 4:49pm UTC](https://discourse.slicer.org/t/how-to-save-the-content-of-a-qtablewidget-in-a-mrb-file/27480/2 "2023-01-26T16:49:21Z")

</div>

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](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#using-mrml-classes-only)).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 26, 2023, 11:14pm UTC](https://discourse.slicer.org/t/how-to-save-the-content-of-a-qtablewidget-in-a-mrb-file/27480/3 "2023-01-26T23:14:28Z")

</div>

You can also display the MRML table in your module widget using a [qMRMLTableView](https://apidocs.slicer.org/master/classqMRMLTableView.html). 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.

---

<div class="post-metadata">

**Author:** ![JessevdO](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@JessevdO](https://discourse.slicer.org/u/JessevdO)\
**Post date:** [February 2, 2023, 10:36am UTC](https://discourse.slicer.org/t/how-to-save-the-content-of-a-qtablewidget-in-a-mrb-file/27480/4 "2023-02-02T10:36:17Z")

</div>

Thank you gentleman! That is exactly what I wanted 🙂
