how to get the wheel event from the qwebenginview widget?
-
page()->settings()->setAttribute(QWebEngineSettings::ShowScrollBars,false);I hided the scrollbar of the qwebengineview widget.
and I implemented the wheelEvent from the qwebengineview ,but u know it didnt work.
I guess maybe I'm get the wrong event function.Please tips me. -
page()->settings()->setAttribute(QWebEngineSettings::ShowScrollBars,false);I hided the scrollbar of the qwebengineview widget.
and I implemented the wheelEvent from the qwebengineview ,but u know it didnt work.
I guess maybe I'm get the wrong event function.Please tips me.@nicker-player
You migth show what you tried for the wheel event, and state what "t didnt work" means in practice. Depending you might look at the example at https://stackoverflow.com/a/69999649/489865 if it relates to your situation. -
@nicker-player
You migth show what you tried for the wheel event, and state what "t didnt work" means in practice. Depending you might look at the example at https://stackoverflow.com/a/69999649/489865 if it relates to your situation.bool WidgetBrowser::eventFilter(QObject *obj, QEvent *e){ if (obj == this) { if (e->type() == QEvent::Wheel){ QWheelEvent* event =(QWheelEvent*)e; int det = event->angleDelta().y(); emit onSignalWheel(event); } } return QWidget::eventFilter(obj, e); }I put the code into the project.but the webengineview could not get the event from the webview.I dont know why.maybe it is related to the chrome framework?
-
bool WidgetBrowser::eventFilter(QObject *obj, QEvent *e){ if (obj == this) { if (e->type() == QEvent::Wheel){ QWheelEvent* event =(QWheelEvent*)e; int det = event->angleDelta().y(); emit onSignalWheel(event); } } return QWidget::eventFilter(obj, e); }I put the code into the project.but the webengineview could not get the event from the webview.I dont know why.maybe it is related to the chrome framework?
@nicker-player
The stackoverflow solution states and shows it is usingfocusProxy(), that was the whole point of it. So did you try that? -
If you want to use
eventFilteryou need to write a different class (just derived from QObject) that has the event filter and then callinstallEventFilteron your instance ofWidgetBrowserwith an object that has eventFilter implemented. -
If you want to use
eventFilteryou need to write a different class (just derived from QObject) that has the event filter and then callinstallEventFilteron your instance ofWidgetBrowserwith an object that has eventFilter implemented.@SimonSchroeder
Have you/the OP looked at the stackoverflow link showing what to do? No other/different class, beyond theQWebEngineView-derived class, which I presume is the OP'sWidgetBrowser. It shows exactly what they want you to try, see the use offocusProxy()..... -
@SimonSchroeder
Have you/the OP looked at the stackoverflow link showing what to do? No other/different class, beyond theQWebEngineView-derived class, which I presume is the OP'sWidgetBrowser. It shows exactly what they want you to try, see the use offocusProxy().....@JonB said in how to get the wheel event from the qwebenginview widget?:
what to do? No other/different class, beyond the
Ive tried the code is object->parent(),it seemed works fine.
not the focusProxy() part.now I will tried the focusProxy() method .
I dont understand the focusProxy usage. -
@SimonSchroeder
Have you/the OP looked at the stackoverflow link showing what to do? No other/different class, beyond theQWebEngineView-derived class, which I presume is the OP'sWidgetBrowser. It shows exactly what they want you to try, see the use offocusProxy().....@JonB said in how to get the wheel event from the qwebenginview widget?:
It shows exactly what they want you to try, see the use of focusProxy()
But don't you have to install the eventFilter somewhere in order to catch/filter the events? I think this is what @SimonSchroeder is talking about, which was not done in the StackOverflow example. IIRC the
eventFilterwon't receive all events just like that. Only if there's a "filtering object" set withwebengine->installEventFilter(observer).
I'm not sure if the filter and the filtered object can be the sameQObject. Never tried it.Edit:
Never mind, the filter is installed onfocusProxy()QObject... -
@JonB said in how to get the wheel event from the qwebenginview widget?:
It shows exactly what they want you to try, see the use of focusProxy()
But don't you have to install the eventFilter somewhere in order to catch/filter the events? I think this is what @SimonSchroeder is talking about, which was not done in the StackOverflow example. IIRC the
eventFilterwon't receive all events just like that. Only if there's a "filtering object" set withwebengine->installEventFilter(observer).
I'm not sure if the filter and the filtered object can be the sameQObject. Never tried it.Edit:
Never mind, the filter is installed onfocusProxy()QObject...@Pl45m4 said in how to get the wheel event from the qwebenginview widget?:
Never mind, the filter is installed on focusProxy() QObject...
Yes that was what I was drawing attention to for the OP. I don't know but the SO poster was saying mouse events (including wheel) go to
focusProxy().