Why scrolling QScrollArea stops when cursor reaches disabled QCheckBox?



  • Enabled QCheckBox can be scrolled past without a problem. I implented wheelEvent on my QComboBox class to ignore it = let parent do the scrolling. Neither wheelEvent or mouseMoveEvent on QCheckBox handle any scrolling and reimplementing them makes no difference.

    I tried to filter wheel events this way, but QCheckBox is no longer even drawn.

    bool event(QEvent *e)
    {
        if(QEvent::Wheel == e->type())
        {
            e->ignore();
        }
        else e->accept();
        return false;
    }
    

    How can I make mouse wheel events always be passed to the parent QScrollArea?


  • Moderators

    Don't always return false. Returning false means "I don't care about this event". This means you're discarding all events that come to the checkbox, which includes paintng, resizes etc. That's not what you want.

    Instead discard only the wheel event and call base implementation otherwise:

    bool event(QEvent* e)
    {
        if (QEvent::Wheel == e->type())
            return false;
    
        return QCheckBox::event(e);
    }
    


  • Thanks. Works great.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.