Why `qMRMLThreeDWidget` is not supposed to be inherited


I wanted to set custom qMRMLThreeDViewControllerWidget to the qMRMLThreeDWidget . But qMRMLThreeDWidgetPrivate is declared and defined within qMRMLThreeDWidget.cxx (i.e. there is no qMRMLThreeDWidget_p.h file). Also there is no protected constructor for inherited classes that follows pimpl idea.

Was it hidden intensionally or is it some kind of a drawback?

By the way the similar class qMRMLSliceWidget has qMRMLSliceWidget_p.h header and Slicer Astro uses it to add custom button.

Keeping certain implementation details private is essential for keeping enough degree of freedom for Slicer core developers to make changes without worrying that those changes may break extensions. Pluggable interfaces are available for many things, but implementing and maintaining these interfaces takes significant effort, so they only exist if there is a strong, confirmed need.

qMRMLThreeDWidget is a tiny class, that it is easier for developers to clone and modify rather than implement an API in Slicer core to inject a custom view controller widget or make it usable as a base class. You can also add/remove buttons dynamically at runtime with standard Qt API. But if you have any specific suggestion for changing the API - preferably without taking on significant development effort and maintenance commitment - then let us know.

1 Like