Wheel event forwarding.
This commit is contained in:
parent
4c6a882e86
commit
ecd9c29a96
@ -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
|
||||
|
@ -68,6 +68,7 @@ protected:
|
||||
void handleMouseEvent(QMouseEvent *);
|
||||
void handleMoveEvent(QMoveEvent *);
|
||||
void handleResizeEvent(QResizeEvent *);
|
||||
void handleWheelEvent(QWheelEvent *);
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
|
Loading…
Reference in New Issue
Block a user