I'm trying to subclass QCheckBox
to make it pass mouse clicks through if disabled. When my checkbox is not disabled (isEnabled()
is true
), Qt calls its mousePressEvent()
as expected. When it is disabled, calls do not happen. Any ideas how to outmaneuver it?
What you describe is indeed the documented behavior. If you look at the source code, you will see that QWidget::event
only calls mousePressEvent
if the widget is enabled.
As a solution, you may override event
instead of mousePressEvent(QEvent *e)
and check if e->type() == QEvent::MouseButtonPress
.