From ab5321a93c4bcbd366b1fc4481029d6766f4c1c8 Mon Sep 17 00:00:00 2001 From: hujinyang Date: Mon, 19 Jan 2026 08:02:27 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- widgets.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 widgets.py diff --git a/widgets.py b/widgets.py new file mode 100644 index 0000000..eec67f7 --- /dev/null +++ b/widgets.py @@ -0,0 +1,17 @@ +'''自定义控件实现''' +from PyQt6.QtWidgets import QSpinBox, QDoubleSpinBox +from PyQt6.QtCore import Qt + +class NoWheelSpinBox(QSpinBox): + """禁用鼠标滚轮的SpinBox""" + def wheelEvent(self, event): + event.ignore() + +class NoWheelDoubleSpinBox(QDoubleSpinBox): + """禁用鼠标滚轮的DoubleSpinBox""" + def wheelEvent(self, event): + event.ignore() + + def setDecimalsFromRules(self, decimals): + """根据规则设置小数位数""" + self.setDecimals(decimals) \ No newline at end of file