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.
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.
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.