[PyKDE] QSpinBox wheelEvents

Hans-Peter Jansen hpj at urpla.net
Fri Jun 16 20:28:08 BST 2006


Hi Ken,

Am Freitag, 16. Juni 2006 20:08 schrieb EXT-Harris, Kenneth B:
> Hi all,
>
> I'm using PyQt 3.3.x on Windows XP, and my task today is to disable
> mouse-wheel events for QSpinBoxes.  Specifically, it's in a scrolling
> view, and I want scroll-wheel events to scroll the whole pane, not
> change the QSpinBox value.
>
> My first idea was to override wheelEvent() in a subclass -- I did
> this for QComboBox successfully -- but this didn't work for
> QSpinBoxes.
>
> So I emailed the Qt folks, and they kindly responded with a
> workaround: override eventFilter(), and catch wheel-events there.  I
> tried this in my PyQt3, and it works if your pointer is over the
> QLineEdit part of the QSpinBox.  Unfortunately, if your pointer is
> over the 1-px border on the top/left/bottom sides, or over the little
> arrows on the right side, the mousewheel still does its normal thing.
>  I can't figure out how to receive those events: they don't call
> either eventFilter() or wheelEvent().
>
> The Qt guy claimed, however, that it works correctly (with the mouse
> anywhere) in Qt, but he hasn't tried PyQt.  I haven't confirmed this.
> (Apologies.  C++ on Windows is really not my forte.)
>
> They also told me that it's possible to simply override wheelEvent()
> in Qt 4, as expected.  If it turns out the easiest way to fix this in
> PyQt3 is Really Hard, that's good incentive to try PyQt4.  :-)

Overiding event methods won't work for Qt3 container widgets, since the 
event is directed to the underlying widgets.

> Is this a limitation of PyQt3?  And regardless of whose fault it may
> be, is there a workaround?

It's all a matter of where you install the event filter, and how much 
dirty tricks you can stand ;-). See attached script et.py as a starter.

Hth,
Pete
-------------- next part --------------
A non-text attachment was scrubbed...
Name: et.tar.gz
Type: application/x-tgz
Size: 3297 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060616/c341cbd4/et.tar.bin


More information about the PyQt mailing list