Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-46251

QML WebEngineView can not deal with key event

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.8, 5.10.0 Alpha, 5.9
    • Fix Version/s: None
    • Component/s: WebEngine
    • Labels:
      None
    • Environment:
      Qt 5.4.0 vs2013 win7

      Description

      in qml project key event can not work with WebEngineView

      /* key event cannot work with WebEngineView*/
      import QtQuick 2.1
      import QtQuick.Controls 1.1
      import QtWebEngine 1.0
      
      ApplicationWindow {
          width: 1280
          height: 720
          visible: true
          WebEngineView {
              id: webview
              url: "http://www.qt-project.org"
              anchors.fill: parent
      
              focus: true;
              Keys.onPressed: {
                  if(event.key == Qt.Key_Escape || event.key == Qt.Key_Back)
                  {
                      console.log("xxxxxxxxxxxxxxxxx");
                      Qt.quit();
                  }
                  else
                  {
                      console.log("yyyyyyyyyyyyyyyyyyy");
                  }
              }
          }
      
          Rectangle {
              anchors.fill: parent;
      
              focus: true;
              color: Qt.rgba(0, 0, 0, 0.2);
      
              Keys.onPressed: {
                  if(event.key == Qt.Key_Escape || event.key == Qt.Key_Back)
                  {
                      console.log("xxxxxxxxxxxxxxxxx");
                      Qt.quit();
                  }
                  else
                  {
                      console.log("yyyyyyyyyyyyyyyyyyy");
                  }
              }
          }
      }
      
      /* key event work will  without WebEngineView*/
      import QtQuick 2.1
      import QtQuick.Controls 1.1
      import QtWebEngine 1.0
      
      ApplicationWindow {
          width: 1280
          height: 720
          visible: true
          Rectangle {
              anchors.fill: parent;
      
              focus: true;
              color: Qt.rgba(0, 0, 0, 0.2);
      
              Keys.onPressed: {
                  if(event.key == Qt.Key_Escape || event.key == Qt.Key_Back)
                  {
                      console.log("xxxxxxxxxxxxxxxxx");
                      Qt.quit();
                  }
                  else
                  {
                      console.log("yyyyyyyyyyyyyyyyyyy");
                  }
              }
          }
      }
      

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              qt_webengine_team Qt WebEngine Team
              Reporter:
              cbdg cbdg0222
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes