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

WebView doesn't handle non-persistent SG and GL

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.4.0 Beta
    • 5.3.1
    • WebKit
    • None
    • 3df57f7e550a19cb4450ed3896aa51ddb38c2ed2 def5fef7fbf7fedece54d52188f75a90616599a4

    Description

      main.cpp

      #include <QtQuick>
      #include <QtGui>
      #include <QtCore>
      
      int main(int argc, char **argv)
      {
          QGuiApplication app(argc, argv);
      
          QQuickView view;
          view.setGeometry(100, 100, 400, 400);
          view.setSource(QUrl::fromLocalFile("main.qml"));
          view.setResizeMode(QQuickView::SizeRootObjectToView);
          view.setPersistentOpenGLContext(false);
          view.setPersistentSceneGraph(false);
          view.rootContext()->setContextProperty("window", &view);
          view.show();
      
          app.exec();
      }
      

      main.qml

      import QtQuick 2.0
      import QtWebKit 3.0
      import QtQuick.Window 2.0
      
      Item {
      
          width: 640
          height: 480
      
          WebView {
              id: webview
              url: "http://reddit.com"
              anchors.fill: parent
              onNavigationRequested: {
                  // detect URL scheme prefix, most likely an external link
                  var schemaRE = /^\w+:/;
                  if (schemaRE.test(request.url)) {
                      request.action = WebView.AcceptRequest;
                  } else {
                      request.action = WebView.IgnoreRequest;
                      // delegate request.url here
                  }
              }
          }
      
          visible: true
      
          Rectangle {
              width: parent.width
              height: 100
              anchors.bottom: parent.bottom;
              color: Qt.rgba(1, 0, 1, 0.5);
              MouseArea {
                  anchors.fill: parent
                  onClicked: {
                      window.visible = false;
                      timer.running = true;
                  }
              }
          }
      
          Timer {
              id: timer;
              running: false
              repeat: false
              interval: 2000
              onTriggered: {
                  window.visible = true;
              }
          }
      }
      

      Click the pink box to hide the window. This starts a timer which will bring the window back two seconds later. When it comes back, the webview doesn't render anymore.

      Attachments

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

        Activity

          People

            jturcott Jocelyn Turcotte
            sletta Gunnar Sletta
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes