Results 1 to 4 of 4

Thread: How to disable wheelEvent()

  1. #1
    Join Date
    Feb 2010
    Location
    Los Angeles
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to disable wheelEvent()

    Dear All,

    I want do disable the wheelEvent for QComboBox, QDoubleSpinBox, and QSpinBox. (They live inside a QWidget which itself lies in a QFrame).

    I tried setFocusPolicy(Qt::ClickFocus or even Qt::NoFocus) but it does not make a difference. As soon as I am with the mouse over those objects the wheelEvent will manipulate them.

    Any idea how to stop the wheelEvent without subclassing all the classes?

    Thanks
    Markus

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to disable wheelEvent()

    Subclassing Or simply install an event filter on that widgets.

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

    Markus (6th August 2010)

  4. #3
    Join Date
    Sep 2009
    Location
    Kraków, Poland
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: How to disable wheelEvent()

    Like it was said install an event filter and handle (or simply not handle) Wheel events by yourself
    Qt Code:
    1. void SomeClass::initializeStuff()
    2. {
    3. m_combo = new QComboBox(this);
    4. m_combo->installEventFilter(this);
    5. }
    6.  
    7. bool SomeClass::eventFilter(QObject *obj, QEvent *event)
    8. {
    9. if(event->type() == QEvent::Wheel && obj == m_combo)
    10. {
    11. qDebug() << "Wheel event blocked";
    12. return true;
    13. }
    14. return false;
    15. }
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to JacquesBaniaque for this useful post:

    Qiieha (15th September 2011)

  6. #4
    Join Date
    Feb 2010
    Location
    Los Angeles
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to disable wheelEvent()

    Danke!

    the event filter works great

Similar Threads

  1. disable alt+tab
    By ahmdsd_ostora in forum Qt Programming
    Replies: 24
    Last Post: 11th July 2010, 10:40
  2. wheelEvent not working in an eventFilter
    By Cruz in forum Qt Programming
    Replies: 7
    Last Post: 1st February 2009, 00:06
  3. override wheelEvent for QScrollBar
    By ChasW in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 10:50
  4. How to disable wheelEvent for scrollbars
    By forrestfsu in forum Qt Programming
    Replies: 7
    Last Post: 11th October 2006, 20:05
  5. Disable Tab Key
    By otortos in forum Newbie
    Replies: 6
    Last Post: 25th March 2006, 17:27

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.