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

QML WebEngineView can not deal with key event

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.8, 5.10.0 Alpha, 5.9
    • WebEngine
    • None
    • 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

              qt_webengine_team Qt WebEngine Team
              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