Commit 34d39816 authored by Victor Poughon's avatar Victor Poughon
Browse files

Merge branch 'filter-wheel-combobox' into 'develop'

Filter mouse wheel event in QComboBox of app parameters

See merge request orfeotoolbox/otb!454
No related merge requests found
Showing with 26 additions and 27 deletions
+26 -27
......@@ -56,8 +56,6 @@ private:
void DoCreateWidget() override;
void DoUpdateGUI() override;
bool eventFilter(QObject * o, QEvent * e) override;
QHBoxLayout * m_QHBoxLayout;
QtWidgetDoubleSpinBox * m_QDoubleSpinBox;
......
......@@ -57,8 +57,6 @@ private:
void DoCreateWidget() override;
void DoUpdateGUI() override;
bool eventFilter( QObject * o, QEvent * e ) override;
QHBoxLayout * m_QHBoxLayout;
QtWidgetSpinBox* m_QSpinBox;
......
......@@ -78,6 +78,8 @@ protected:
Parameter * GetParam();
bool eventFilter(QObject* o, QEvent* e) override;
private:
QtWidgetParameterBase(const QtWidgetParameterBase&) = delete;
void operator=(const QtWidgetParameterBase&) = delete;
......
......@@ -97,6 +97,10 @@ void QtWidgetChoiceParameter::DoCreateWidget()
m_VLayout->addStretch();
this->setLayout(m_VLayout);
// Block mouse wheel events
m_ComboBox->setFocusPolicy(Qt::StrongFocus);
m_ComboBox->installEventFilter(this);
}
void QtWidgetChoiceParameter::SetValue(int value)
......
......@@ -138,16 +138,5 @@ void QtWidgetFloatParameter::OnEditingFinished()
this->GetModel()->NotifyUpdate();
}
// Filter mouse wheel events to avoid scrolling issues in parent QScrollArea
bool QtWidgetFloatParameter::eventFilter(QObject * o, QEvent * e)
{
if ( e->type() == QEvent::Wheel && qobject_cast<QAbstractSpinBox*>( o ) )
{
e->ignore();
return true;
}
return QWidget::eventFilter( o, e );
}
}
}
......@@ -134,17 +134,5 @@ void QtWidgetIntParameter::OnEditingFinished()
this->GetModel()->NotifyUpdate();
}
// Filter mouse wheel events to avoid scrolling issues in parent QScrollArea
bool QtWidgetIntParameter::eventFilter( QObject * o, QEvent * e )
{
if ( e->type() == QEvent::Wheel && qobject_cast<QAbstractSpinBox*>( o ) )
{
e->ignore();
return true;
}
return QWidget::eventFilter( o, e );
}
}
}
......@@ -98,6 +98,10 @@ void QtWidgetOutputImageParameter::DoCreateWidget()
connect( m_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), GetModel(), &QtWidgetModel::NotifyUpdate );
m_HLayout->addWidget(m_ComboBox);
// Block mouse wheel events
m_ComboBox->setFocusPolicy(Qt::StrongFocus);
m_ComboBox->installEventFilter(this);
// Set up input text edit
m_Button = new QPushButton(this);
m_Button->setText("...");
......
......@@ -102,6 +102,17 @@ QtWidgetParameterBase
return m_Param;
}
// Used to block mouse wheel events to avoid conflict with scrolling in the parent QScrollArea
bool QtWidgetParameterBase::eventFilter(QObject* o, QEvent* e)
{
if (e->type() == QEvent::Wheel)
{
e->ignore();
return true;
}
return QWidget::eventFilter(o, e);
}
}
......
......@@ -59,6 +59,11 @@ void QtWidgetRAMParameter::DoCreateWidget()
m_QSpinBox->setRange(itk::NumericTraits<int>::Zero,
itk::NumericTraits<int>::max());
// Block mouse wheel events to the QSpinBox
// this is to avoid grabbing focus when scrolling the parent QScrollArea
m_QSpinBox->setFocusPolicy(Qt::StrongFocus);
m_QSpinBox->installEventFilter(this);
m_QHBoxLayout->addWidget(m_QSpinBox);
m_QHBoxLayout->addStretch();
......
Supports Markdown
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