I have a QHeaderViewsubclass inside a QTreeView subclass, the header provides information to the delegates which affects how they paint themselves. The header receives mouse events that controls these values.
I also wanted my delegate editor widgets to provide the same functionality, but rather than copy and pasting the code that translates the mouse values into values the header could use, I thought it would be easier to re-send the QMouseEvent onto it.
So I copy the event and send it on (as noted in the docs):
QMouseEvent e( event->type(), event->pos(), event->button(),
event->buttons(), event->modifiers() );
Sy_application::sendEvent( &header_, &e );
Only header_ never receives it. Posting the event has the same effect:
QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, event->pos(),
event->button(), event->buttons(),
event->modifiers() );
Sy_application::postEvent( &header_, e );
Why is header_ not receiving the event?
It seems my comment, about nothing in the parent classes causing this, must have been wrong. As an experiment I overrode
event(QEvent* event)in my header class to call the mouse handlers manually, and now it works perfectly:It hasn’t affected the way the header operates normally, at least in so far as the way I am using it.