I have a QWidget containing a Qt3DWindow(). I'd like to be able to "zoom" in and out on a QtEntity, within the Qt3DWindow, using the mouse scroll wheel, while hovering over the window.
I have the functionality working, but only when hovering the mouse outside of the Qt3DWindow frame. Here's my code for initializing the window and processing mouse wheel events.
Window Initialization:
mainView = new Qt3DExtras::Qt3DWindow();
mainView->defaultFramegraph()->setClearColor(QColor(QRgb(0x4d4d4f)));
QWidget *container = QWidget::createWindowContainer(mainView);
Processing wheel events:
void ModelView::wheelEvent(QWheelEvent *event){
QVector3D vec;
vec = cameraEntity->position() - modifier->m_transform->translation();
vec = vec.normalized();
QPoint delta = event->angleDelta();
int zoom_distance = delta.y()*0.01;
vec = cameraEntity->position() - zoom_distance*vec;
cameraEntity->setPosition(vec);
}
What's the trick for overriding the window's mouse grab when hovering over the Qt3DWindow frame?
Thanks in advance for any help.