I want to use QtWebEngine in QML with PyQT. I am trying to run simple example.
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtQuick import QQuickView
from PyQt5.QtQml import QQmlApplicationEngine
if __name__ == '__main__':
app = QApplication(sys.argv)
view = QQmlApplicationEngine('main_2.qml')
#view.show()
app.exec_()
sys.exit()
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: "https://www.qt.io"
}
}
But I've get error:
/usr/bin/python3 /home/unknown/IdeaProjects/new_ui/main.py QQmlApplicationEngine failed to load component file:///home/unknown/IdeaProjects/new_ui/main_2.qml:3 module "QtWebEngine" is not installed
Since PyQt 5.12 QtWebEngineWidgets has been separated into another package called PyQtWebEngine, so you have to install it with:
python -m pip install PyQtWebEngine