Search code examples
qtqtwebkitqwebview

How to filter out «back» events in a [Qt] web view?


I develop an application with WebKit-based forms and it’s important that, when on a form, a user can press Backspace without returning to previous page. How do I do this in QtWebKit?

I found out that one can inherit a class from QWebPage and overload QWebPage::triggerAction() to selectively filter out events, e.g. QWebPage::Back. Nevertheless, it works only on the first page, and if you open another page in the same webview child the triggerAction() overload will not be called.


Solution

  • For now, answer is «there is no simple way to do it». I've got and answer on Qt's bug tracker, see https://bugreports.qt-project.org/browse/QTBUG-35555

    Hope this will be fixed.