[PyQt] PyQt5 support for QtWebEngine (for QML WebEngineView)?
Phil Thompson
phil at riverbankcomputing.com
Mon Sep 12 21:49:10 BST 2016
On 12 Sep 2016, at 9:38 pm, Russell Warren <russ at perspexis.com> wrote:
>
> What do you actually want to use which is missing?
>
> All I'm trying to do is get a WebEngineView to render in QML, per their tiny example here (to start with):
>
> http://doc.qt.io/qt-5/qml-qtwebengine-webengineview.html#initializing-web-engine
>
> (Given that, according to the docs, you don't need to call QtWebEngine.initialize()).
>
> Where does it say that? The docs I see [1] say that "for the web engine view to be rendered, the web engine must be initialized by using QtWebEngine::initialize in the application main source file".
http://doc.qt.io/qt-5/qtwebengine.html#initialize
> When I convert the small C launcher in the example to python and load the qml, I get:
>
> QQmlApplicationEngine failed to load component
> file:///home/russ/code/qml/examples/WEV.qml:3 module "QtWebEngine" is not installed
>
> Here is my python file (a direct translation from the cited docs, minus the unavailable QtWebEngine.initialize()):
>
> #!/usr/bin/env python
> import sys
> from PyQt5 import QtGui, QtQml
> from OpenGL import GL #Linux workaround. See: http://goo.gl/s0SkFl
>
> app = QtGui.QGuiApplication(sys.argv)
> engine = QtQml.QQmlApplicationEngine()
> engine.load("WEV.qml")
> app.exec_()
>
> And the QML file...
>
> import QtQuick 2.0
> import QtQuick.Window 2.0
> import QtWebEngine 1.0
>
> Window {
> width: 1024
> height: 750
> visible: true
> WebEngineView {
> anchors.fill: parent
> url: "http://www.qt.io"
> }
> }
>
> I have tried other python launchers (eg: with QQuickView) and I still run into issues on that qml import of QtWebEngine.
Adding the call to setAttribute() works fine for me.
Phil
More information about the PyQt
mailing list