Touch not working using QVTKOpenGLNativeWidget
Hello @sankhesh @lucas.givord .This issue is related to #18528. Thanks @ikerssm for his solution in !9112 (closed) . But when I use QVTKOpenGLNativeWidget, it's still not working.
QVTKOpenGLNativeWidget
re-implement QObject::event(QEvent *e)
as follow:
bool QVTKOpenGLNativeWidget::event(QEvent* evt)
{
if (this->RenderWindowAdapter)
{
this->RenderWindowAdapter->handleEvent(evt);
}
return this->Superclass::event(evt);
}
However, the Qt document note that we should return true if the event e
was recognized and processed. And We need to call the parent event class implementation if we did not handle, see also https://doc.qt.io/qt-5/qobject.html#event. But QVTKOpenGLNativeWidget
actually always returns the parent event class implementation even the event is handled.
Qt did not give an clear result of this case. According to my issue I guess the parent class implementation QWidget::event(QEvent* evt)
would reset the state of the event, which will cause the missing of QEvent::TouchUpdate
. (Refer to #18533 (comment 1179586))
I suggest that we can fix this by:
bool QVTKOpenGLNativeWidget::event(QEvent* evt)
{
if (this->RenderWindowAdapter)
{
return this->RenderWindowAdapter->handleEvent(evt) ? true : this->Superclass::event(evt);
}
return this->Superclass::event(evt);
}
It works in my case: Linux + Qt6.2.4 + master VTK.