Wheel event forwarding.

This commit is contained in:
Samuel Rødal 2011-05-03 16:41:18 +02:00
parent 4c6a882e86
commit ecd9c29a96
2 changed files with 19 additions and 0 deletions

View File

@ -77,6 +77,10 @@ bool QWidgetWindow::event(QEvent *event)
handleResizeEvent(static_cast<QResizeEvent *>(event));
return true;
case QEvent::Wheel:
handleWheelEvent(static_cast<QWheelEvent *>(event));
return true;
default:
break;
}
@ -127,4 +131,18 @@ void QWidgetWindow::handleCloseEvent(QCloseEvent *)
m_widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
}
void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
{
// which child should have it?
QWidget *widget = m_widget->childAt(event->pos());
if (!widget)
widget = m_widget;
QPoint mapped = widget->mapFrom(m_widget, event->pos());
QWheelEvent translated(mapped, event->globalPos(), event->delta(), event->buttons(), event->modifiers(), event->orientation());
QGuiApplication::sendSpontaneousEvent(widget, &translated);
}
QT_END_NAMESPACE

View File

@ -68,6 +68,7 @@ protected:
void handleMouseEvent(QMouseEvent *);
void handleMoveEvent(QMoveEvent *);
void handleResizeEvent(QResizeEvent *);
void handleWheelEvent(QWheelEvent *);
private:
QWidget *m_widget;