3

I want to deploy one YouTube application in Android. But it only works on my computer, and it does not work on Android. It does not load any video. The problem is only with the QWebView. I used a code similar to this: http://doc.qt.io/archives/qt-5.5/qtwebkitexamples-webkitqml-youtubeview-example.html

Carlos Duarte
  • 99
  • 2
  • 6

2 Answers2

2

Referring to Qt Documentations:

Qt WebEngine is not available on mobile platforms

While

Qt WebView is actually useful for mobile platforms! .. as stated by Qt Here

You can use QwebView with Android , This should be possible with Qt5.x, as follow:

Configure project for Android kit and add QT += webview to your .pro file.

In main.cpp, it's important to call QtWebView::initialize() right after creating the QGuiApplication:

#include <QtWebView>
QGuiApplication app(argc, argv);
QtWebView::initialize();

Now ready to use at qml side:

import QtWebView 1.1

WebView {
        id: webView
        anchors.fill: parent
        url: "http://some/url/"
        onLoadingChanged: {
            if (loadRequest.errorString)
                console.error(loadRequest.errorString);
        }
    }

Check Qt MiniBrowser Exmaple for QwebView with Android.

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
  • @Carlos Duarte, Note that the first answer I think confused you ... the fact is that it is the the opposite. Qt `WebEngineView` works only on Qt for MSVS/Chromium .. while `QwebView` does work on Android, Check [Qt WebView Qt5.10](http://doc.qt.io/qt-5/qtwebview-index.html) – Mohammad Kanan Feb 26 '18 at 14:26
-1

if you are using Qt5. You should use WebEngineView, QWebView will not work on android.

import QtQuick 2.0
import QtWebEngine 1.4

Item{
    id:root
    height: 500
    width:  500

   Rectangle{
      anchors.fill: parent
      color: "black"

      WebEngineView{
         id : webEnginView
         anchors.fill: parent
         url : https://www.google.com
      }
   }
}
SourabhKus
  • 818
  • 8
  • 23
  • for more detail [here](https://stackoverflow.com/questions/43867334/how-to-pass-value-from-qml-to-javascript-in-qwebengineview) – SourabhKus Feb 03 '18 at 08:32