在下拉框所在的cpp中,重写过滤器事件
下面展示一些 内联代码片
。
bool Module_Oscilloscope::eventFilter(QObject *watched, QEvent *event)
{
if(event->type() == QEvent::Wheel) //避免光标放到下拉框时,滚动滚轮,会改变下拉框值
{
if(watched == ui->cmbx_ch_0 || watched == ui->cmbx_ch_1 || watched == ui->cmbx_ch_2 || watched == ui->cmbx_ch_3
|| watched == ui->cmbx_ch_4 || watched == ui->cmbx_ch_5 || watched == ui->cmbx_ch_6 || watched == ui->cmbx_ch_7
|| watched == ui->cmbx_preset_mode)
{
return true;
}
}
return QWidget::eventFilter(watched, event);
}