Results 1 to 5 of 5

Thread: Disable wheel event for a QComboBox inside a QListWidgetItem

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

    Question Disable wheel event for a QComboBox inside a QListWidgetItem

    Hello all,

    I am using a QTablewidget with different widgets in different columns. The trouble begins when there are more rows to fit the view and you need to scroll. One of the columns is holding a QComboBox and when you use the scroll wheel and your mouse happens to be over a column with a QComboBox you scroll the QComboBox instead of the table view. I tried setting:
    Qt Code:
    1. combbbox->setFocusPolicy(Qt::TabFocus);
    To copy to clipboard, switch view to plain text mode 
    but it does not help.

    Any suggestion of how to make it react to a scroll wheel only when it already has focus?

    Markus

  2. #2
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Disable wheel event for a QComboBox inside a QListWidgetItem

    Why not override the mouse wheel event with event->ignore() ?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Disable wheel event for a QComboBox inside a QListWidgetItem

    I expect that reimplementing the QComboBox::wheelEvent() to look something like this would be a start (untested):
    Qt Code:
    1. void MyComboBox::wheelEvent( QWheelEvent * e)
    2. {
    3. if (hasFocus())
    4. QComboBox::wheelEvent(e);
    5. else
    6. e->ignore();
    7. }
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to ChrisW67 for this useful post:

    Markus (19th March 2014)

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

    Default Re: Disable wheel event for a QComboBox inside a QListWidgetItem

    Thanks, sub-classing will work. I was wondering if there is another way.

  6. #5
    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: Disable wheel event for a QComboBox inside a QListWidgetItem

    The cleaner approach is to do the override event handling in a subclass, but you can always install an event filter instead.

    See QObject::eventFilter()

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 16th July 2012, 10:56
  2. QTextEdit+resize text on wheel event
    By gaczm in forum Newbie
    Replies: 2
    Last Post: 2nd August 2011, 19:30
  3. Rich Text Inside QListWidgetItem?
    By Jick in forum Newbie
    Replies: 1
    Last Post: 17th February 2010, 02:30
  4. QGLWidget and wheel event
    By shenakan in forum Qt Programming
    Replies: 1
    Last Post: 6th November 2009, 16:21
  5. wheel event problem
    By bhogasena in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2009, 20:11

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.