[Qtwebengine] KeyPressEvent not implemented?

Florian Bruhin me at the-compiler.org
Fri Jan 16 22:05:12 CET 2015


* David Cortesi <davecortesi at gmail.com> [2015-01-16 12:55:00 -0800]:
> I converted a simple browser app to use QWebEngineView from QWebView. In
> the original QWebView widget I had an overriding keyPressEvent() handler
> which worked.

Out of curiosity: What are you working on exactly?

> Now that my widget is derived from QWebEngineView, the keyPressEvent
> handler is never entered. I have set self.focusPolicy(Qt::StrongFocus) and
> I can click in the web view, and when keys are pressed, no events are
> passed to the handler.
> 
> Is this a known restriction of the new QWebEngineView? Certainly
> QWidget::keyPressEvent() does appear in the list of all members in the doc.

I think this is the same limitation as in
https://bugreports.qt.io/browse/QTBUG-43602

    Mouse events are caught by a child QWidget of the QWebEngineView,
    and not by the QWebEngineView itself. This is a limitation of the
    current QtWebEngine design.

There are also two workarounds mentioned there:

    A workaround could be to monitor QObject::childEvent of the
    QWebEngineView and install an event filter when a new child
    QWidget appear during page loads. I haven't tried this approach
    myself though, it might not be as reliable as needed for various
    reasons, and might break in future releases if the way we parent
    widgets internally changes.

    Another way would be to wrap the QWebEngineView (and its children)
    in a QWidget sandwich where a "glass" sibbling placed on top of
    the webview would catch any mouse event before it reaches the
    QWebEngineView's children under it.

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/qtwebengine/attachments/20150116/f1050466/attachment.sig>


More information about the QtWebEngine mailing list