Results 1 to 2 of 2

Thread: Help with QWheelEvent

  1. #1
    Join Date
    Nov 2012
    Location
    Kentucky, USA
    Posts
    46
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Help with QWheelEvent

    I need to change values in a line edit with the mouse wheel. Can't seem to find any examples of using the wheelEvent on line edit and the doc isn't helping me much.
    Any pointers on how to do this?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Help with QWheelEvent

    For any kind of custom event handling, one usually creates a new class which is a sub class of the one need, in your case derive from QLineEdit.

    Then you can override event handling by reimplementing protected event handling methods, in your case wheelEvent(QWheelEvent*).
    The QWheelEvent class has a method called delta() which is either greather than 0 or less than zero, basically a value how "far" the wheel has been turned in either direction.

    There is also the option of installing an event filter on the widget instead of subclassing, but usually having a concrete class with the new functionality is better in the long run.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    K4ELO (10th March 2013)

Similar Threads

  1. Pass event (QWheelEvent) to a specific widget
    By stefanadelbert in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2021, 03:10
  2. Replies: 1
    Last Post: 1st December 2011, 21:47
  3. QWheelEvent: checking if wheel has stopped
    By papillon in forum Qt Programming
    Replies: 4
    Last Post: 30th September 2011, 13:03
  4. Replies: 2
    Last Post: 19th July 2011, 10:06
  5. Create a QWheelEvent and pass it to a widget's wheelEvent
    By almagest in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2010, 13:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.