diff --git a/Orange/widgets/data/owcreateinstance.py b/Orange/widgets/data/owcreateinstance.py index 08869243bf1..2b100c5fdd6 100644 --- a/Orange/widgets/data/owcreateinstance.py +++ b/Orange/widgets/data/owcreateinstance.py @@ -5,7 +5,7 @@ import numpy as np from AnyQt.QtCore import Qt, QSortFilterProxyModel, QSize, QDateTime, \ - QModelIndex, Signal, QPoint, QRect + QModelIndex, Signal, QPoint, QRect, QEvent from AnyQt.QtGui import QStandardItemModel, QStandardItem, QIcon, QPainter from AnyQt.QtWidgets import QLineEdit, QTableView, QSlider, \ QComboBox, QStyledItemDelegate, QWidget, QDateTimeEdit, QHBoxLayout, \ @@ -163,6 +163,9 @@ def deselect(): # self._spin.lineEdit().selectionChanged only for editor creation. self._spin.lineEdit().selectionChanged.connect(deselect) + self._slider.installEventFilter(self) + self._spin.installEventFilter(self) + @property def value(self) -> float: return self.__round_value(self._value) @@ -195,6 +198,12 @@ def __map_to_slider(self, value: float) -> int: def __map_from_slider(self, value: int) -> float: return value * 10 ** (-self._n_decimals) + def eventFilter(self, obj: Union[QSlider, QDoubleSpinBox], event: QEvent) \ + -> bool: + if event.type() == QEvent.Wheel: + return True + return super().eventFilter(obj, event) + class StringVariableEditor(VariableEditor): value_changed = Signal() @@ -252,6 +261,8 @@ def sizeHint(self) -> QSize: self.layout().addWidget(self._edit) self.setFocusProxy(self._edit) + self._edit.installEventFilter(self) + @property def value(self) -> float: return self._value @@ -273,6 +284,11 @@ def __map_to_datetime(self, value: float) -> QDateTime: return QDateTime.fromString(self._variable.repr_val(value), self._format) + def eventFilter(self, obj: QDateTimeEdit, event: QEvent) -> bool: + if event.type() == QEvent.Wheel: + return True + return super().eventFilter(obj, event) + class VariableDelegate(QStyledItemDelegate): def paint(self, painter: QPainter, option: QStyleOptionViewItem,