Notification when `qMRMLSliceWidget` added


Is there some kind of signal when qMRMLSliceWidget added?

I’m trying to add a toolbutton to it and there is no preblem to do that on existing qMRMLSliceWidget (there is an example in scrit repo) but when new slice widget is added I need to add the same button to it.

You can observe the layout changed signal of the layout manager.

1 Like

Thank you for help,

I also found qMRMLLayoutViewFactory::viewCreated(QWidget*) (though as I understood it always emit nullptr).

And I reach the factory with:

  qMRMLLayoutViewFactory* factory = app->

What is the preferred solution: connect to layout manager or to factory?

Adding a connection to the viewCreated signal to every view types you are interested in should work, too. That signal emits a valid pointer to the widget that has just been created.

1 Like

I may be mistaken but in the Slicer’s source code view factory viewCreated(viewWidget) signal is emitting with widget that is created with createViewFromNode(vtkMRMLAbstractViewNode* viewNode) function that always returns nullptr

Is implementation of QWidget* qMRMLLayoutViewFactory::createViewFromNode(vtkMRMLAbstractViewNode* viewNode) is correct?

P.S. I’m able to catch the viewCreated signal but it is sent with nullptr parameter:

createViewFromNode method is overridden in concrete factory classes (see qMRMLLayoutManager.cxx). You can add a breakpoint at emit viewCreated(viewWidget); and see that viewWidget is not a nullptr.

Most likely something is wrong where you set up the connection between the signal and your slot.

1 Like

I see now, thank you for explanation