[Solved] disable mouse wheel event on ComboBox

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

[Solved] disable mouse wheel event on ComboBox

Post by fc_tofu »

I have seen some thread complaining about mouse wheel event on ComboBox control.
https://forum.freecadweb.org/viewtopic.php?f=3&t=45144

Till recent FreeCAD build (0.19.21049/win64 Conda) , this issue has not been solved. I'm not coder, and cannot fully understand the difficulty of this issue, but found this issue has got solved elsewhere on the net.

https://bugreports.qt.io/browse/QTBUG-48620
https://stackoverflow.com/questions/330 ... 7#46742557
https://doc.qt.io/qt-5/qml-qtquick-cont ... abled-prop
https://stackoverflow.com/questions/324 ... -qcombobox
Last edited by fc_tofu on Sat Jun 13, 2020 2:36 pm, edited 4 times in total.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by openBrain »

FreeCAD doesn't use Qt Quick.
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by wmayer »

Code: Select all

from PySide2 import QtCore
from PySide2 import QtWidgets

class WheelEventFilter(QtCore.QObject):
    def eventFilter(self, obj, ev):
        if obj.inherits("QComboBox") and ev.type() == QtCore.QEvent.Wheel:
            return True
        return False


app = QtWidgets.QApplication.instance()
filter = WheelEventFilter()
app.installEventFilter(filter)
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by fc_tofu »

openBrain wrote: Sat May 16, 2020 8:00 am FreeCAD doesn't use Qt Quick.
Thanks for correcting my naive mistake.
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by fc_tofu »

wmayer wrote: Sat May 16, 2020 8:16 am

Code: Select all

from PySide2 import QtCore
...
Thank you.
Is there a plan to merge this fix to main branch of FreeCAD?
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [Solved] Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by wmayer »

git commit c90db641881
In order to activate the filter you must create the boolean key ComboBoxWheelEventFilter in the group General and set it to true.
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: [Solved] Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by fc_tofu »

wmayer wrote: Fri May 22, 2020 8:46 am git commit c90db641881
In order to activate the filter you must create the boolean key ComboBoxWheelEventFilter in the group General and set it to true.
Good news!
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: [Solved] Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by fc_tofu »

wmayer wrote: Fri May 22, 2020 8:46 am git commit c90db641881
In order to activate the filter you must create the boolean key ComboBoxWheelEventFilter in the group General and set it to true.
Thank you @wmayer, I just tested the latest build.
It seems your fix has already worked in ComboBox and ListBox(?).

With ListBox (I donnot know its exact name), I mean below.
https://forum.freecadweb.org/viewtopic.php?f=3&t=45144

Above all, manual added parameter “ComboBoxWheelEventFilter” is a must.

Congratulations!

Code: Select all

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21280 (Git)
Build type: Release
Branch: master
Hash: 6f3160db3e88733536c7eaf97ad7d6ebd21baccd
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: Chinese/China (zh_CN)
Last edited by fc_tofu on Wed Jun 03, 2020 7:26 am, edited 1 time in total.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: [Solved] Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by openBrain »

wmayer wrote: Fri May 22, 2020 8:46 am git commit c90db641881
In order to activate the filter you must create the boolean key ComboBoxWheelEventFilter in the group General and set it to true.
Newly introduced parameter is now documented in Fine-tuning

@wmayer : could you please extend the event filter to also return false on QAbstractSpinBox class ? Spin boxes suffer the same issue as combo boxes. Thx.
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: [Solved] Qt Quick Controls 2 ComboBox disable mouse wheel event

Post by fc_tofu »

openBrain wrote: Tue Jun 02, 2020 8:18 pm @wmayer : could you please extend the event filter to also return false on QAbstractSpinBox class ? Spin boxes suffer the same issue as combo boxes. Thx.
With SpinBox, you mean below?
fsc_2020-06-03_152425.jpg
fsc_2020-06-03_152425.jpg (32.95 KiB) Viewed 2358 times
Post Reply