Simple but not obvious fix... The QTextEdit is a subclass
of QAbstractScrollArea, and this superclass actually receives the wheel
events on its viewport. So what you really want to do is filter on the
viewport():

http://pastebin.com/xnYLk1QE

[snip]
        self.te_viewport = self.te.viewport()
        self.te_viewport.installEventFilter(self)
[/snip]

One thing I also like to do is use  "obj is x" instead of "obj == x" as the
former simply checks the id to see if its exactly the same object, as
opposed to performing an equality test (which could be faster depending on
the object you are comparing).

Also, you can optionally do an "event.accept()" before returning True to
prevent any propagation upwards to the parent. Basically you are saying you
handled the event and no other widget should get a chance to see it. If you
do want the wheel event passed up to a parent for a chance to do something
with it, then continue to not accept it.



On Tue, Apr 2, 2013 at 1:09 PM, Manuel Macha <[email protected]> wrote:

> I'm trying to disable the mouse-wheel on a widget using an eventFilter.
> Unfortunately it's not working as expected - code:
> http://pastebin.com/KEjdRKmu
> First of all the wheel event seems to be only triggered if the
> scrollbarHandle is at it's minimum or maximum and I'm trying to scroll
> above it's limits. Also, afaik simply returning True should be sufficient
> for stopping the event propagation but that doesn't seem to to be the case.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to