Subtracting UI components from ModelBuilder


There are many parts of ParaView (and thus ModelBuilder) that preprocessing applications may not want to expose to users. To deal with this, we are adding (in SMTK MR 1690) a new class to the smtkPQComponentsExt library named pqSMTKSubtractUI. This class allows plugins to make user interface components inaccessible to users (and restore them as needed).


  • While there are methods that accept UI-component labels/titles as they are presented to users, it is best if you use the methods that take an object name (i.e., names provided to the QObject by the developer and returned by the QObject::objectName() method.
  • Note that some menu items are added to menus after the event loop has started; thus we must queue a timer onto the event loop to ensure they are present so that we can remove them.
  • Similarly, some panels require a ~1 second delay before they can be reliably hidden (at startup). I have not tried to debug why this is required.
  • A useful tool for identifying object names and title strings that the pqSMTKSubtractUI class accepts is GammaRay.


Let’s say you have a ParaView autostart plugin. In its startup() method, you can remove components like so:

#include "smtk/extension/paraview/appcomponents/pqSMTKSubtractUI.h"
#include <QTimer>

void ExamplePlugin::startup()
  // Ensure the event loop has started by queuing a timer
  // event to do the actual work:
  QTimer::singleShot(900, this, [this]()
    auto subtractor = pqSMTKSubtractUI::instance();
    // Turn "File->Open" off
    subtractor->toggleMenuItem("&File->&Open...", "->", true);
    // Turn "File->Open" back on
    subtractor->toggleMenuItemByObjectName("actionFileOpen", false);
    // Turn the property inspector off (NB: This is what requires the 900ms delay)
    subtractor->togglePanel("Properties", true);
    // Hide a toolbar button (either will work, we match on either text or object name):
    subtractor->toggleToolbarButton("SMTK Selection Filters", "actionSelnAcceptMeshSets", true);
    subtractor->toggleToolbarButton("SMTK Selection Filters", "Select mesh sets", true);
    // Hide a toolbar
    subtractor->toggleToolbar("SMTK Selection Filters", true);
Privacy Notice