Commit 4bcfa9f0 authored by David Thompson's avatar David Thompson

Hide widgets when qt partner is not visible.

parent 617f6098
Pipeline #148735 passed with stage
......@@ -2,6 +2,9 @@
### Widgets
Now, all of the 3-d widgets will be hidden when their Qt partner-widget
is not visible (and visibility will be restored when this changes).
The box widget (pqSMTKBoxItemWidget) now supports a binding that allows
the visibility of the widget to be mapped to a discrete-valued string
item with enumerants "active" and "inactive".
......@@ -262,6 +262,30 @@ void pqSMTKAttributeItemWidget::acceptWidgetValues()
bool pqSMTKAttributeItemWidget::eventFilter(QObject* obj, QEvent* event)
if (obj != this)
bool isHide = event && event->type() == QEvent::Hide;
bool isShow = event && event->type() == QEvent::Show;
pqInteractivePropertyWidget* ww = this->propertyWidget();
if (obj == ww && (isHide || isShow))
return this->qtItem::eventFilter(obj, event);
void pqSMTKAttributeItemWidget::update3DWidgetVisibility(bool visible)
pqInteractivePropertyWidget* ww = this->propertyWidget();
if (ww)
/// Initialize Qt widgets used to represent our smtk::attribute::Item.
void pqSMTKAttributeItemWidget::createWidget()
......@@ -405,12 +429,19 @@ void pqSMTKAttributeItemWidget::createEditor()
// When the active view changes, move the widget to that view.
QObject::connect(&actives, SIGNAL(viewChanged(pqView*)), pvwidget, SLOT(setView(pqView*)));
// Install an event filter on the widget to detect visibility changes so
// we can give 3-d widgets the opportunity to hide themselves when the Qt
// widget is hidden.
this->m_p->m_layout->addLayout(editorLayout, 0, 1);
// Finally, hide widgets not in currently-displayed tabs
bool pqSMTKAttributeItemWidget::validateControlItem(const smtk::attribute::StringItemPtr& item)
......@@ -108,6 +108,16 @@ protected slots:
virtual void acceptWidgetValues();
/// An event filter that watches for the associated Qt widget to be hidden
/// or shown. When this happens, update3DWidgetVisibility() is invoked.
bool eventFilter(QObject* obj, QEvent* event) override;
/// Hide 3-d widgets when the Qt widget is hidden, show the widget when
/// the Qt widget reappears.
/// Subclasses may override update3DWidgetVisibility() if they do not
/// want to inherit the default behavior.
virtual void update3DWidgetVisibility(bool visible);
void createWidget() override;
virtual void clearChildWidgets();
virtual void updateUI();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment