[Paraview-developers] QToolBar plugin for ParaView

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Thu Jan 18 09:46:07 EST 2018


Sure! Alternatively, we could just add a new plugin type to add a
toolbar. I can see how it could be easier for some developers to just
add custom QToolBar rather than doing the same via QActionGroup
interface.

Utkarsh

On Wed, Jan 17, 2018 at 2:32 PM, David Thompson
<david.thompson at kitware.com> wrote:
> Hi all,
>
> I'm working on a ParaView plugin that adds a toolbar. The problem is that the toolbar needs to hold a QWidget (a QComboBox), not a QAction. This doesn't seem supported by ParaView because it does not provide access to its QMainWindow and insists on creating menus/toolbars itself without giving the plugin access to them.
>
> I have a small change to the pqPluginActionGroupBehavior that will provide more flexibility (see below) and will submit a MR if people agree that it's the right way to go about things. The approach it takes is to check the QActionGroup defined in the plugin for a method named "customizeToolBar(QToolBar*)" and call it with the newly-constructed tool bar if the method exists. Any comments?
>
>         Thanks,
>         David
>
> PS. This change, plus the addition of an include for <QMetaObject> are all that's needed:
>
> @@ -108,7 +110,17 @@ void pqPluginActionGroupBehavior::addPluginInterface(QObject* iface)
>    {
>      QToolBar* tb = new QToolBar(splitName[1], mainWindow);
>      tb->setObjectName(splitName[1]);
> -    tb->addActions(agi->actionGroup()->actions());
> +    auto actionGroup = agi->actionGroup();
> +    tb->addActions(actionGroup->actions());
> +    // If the action group has a public slot named "customizeToolBar" that accepts
> +    // a toolbar pointer, invoke that method so that custom widgets may be added.
> +    if (actionGroup->metaObject()->indexOfSlot("customizeToolBar(QToolBar*)") >= 0)
> +    {
> +      QMetaObject::invokeMethod(
> +        actionGroup, "customizeToolBar",
> +        Qt::DirectConnection,
> +        Q_ARG(QToolBar*, tb));
> +    }
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=Paraview-developers
>
> Follow this link to subscribe/unsubscribe:
> https://paraview.org/mailman/listinfo/paraview-developers


More information about the Paraview-developers mailing list