How to superimpose a QML over the QWebEngineView
-
I am trying to place a tool bar designed with QML over the QWebEngineView. But only the page is loaded, the tool bar is not getting loaded.
I would like to know what I am missing.Main.cpp
#include <QApplication>
#include "WebEngineView.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
WebEngineView *weView = new WebEngineView();
weView->show();return app.exec();
}
WebEngineView.cpp
WebEngineView::WebEngineView()
{
this->setUrl(QUrl("http://www.google.co.in"));
QQmlEngine engine;
QQmlContext *objectContext = new QQmlContext(engine.rootContext());
objectContext->setContextProperty("we",this);
QQmlComponent component(&engine);
component.loadUrl(QUrl("qrc:/ReaderToolBar.qml"));
QObject *object = component.create(objectContext);
}ReaderToolBar.qml
Rectangle{
id: tbrect
objectName: "ReadToolBar"
width: 100
height: 70
color: "transparent"
visible: trueMouseArea { anchors.fill: parent hoverEnabled: true }
function showicons()
{
tbicon.visible = true
libicon.visible = true
}Image {
id: libicon
x: 30
smooth: true
height: 36
width: 36
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
source: "qrc:/images/library.png"
visible: trueMouseArea { id: libiconma anchors.fill: parent onClicked: { //rw.showlibrary() console.log("library") hideicons() // hidetables() } } } Image { id: tocicon x: 90 smooth: true height: 50 width: 50 anchors.bottom: parent.bottom //anchors.bottomMargin: 2 source: "qrc:/images/toc.png" visible: true MouseArea { anchors.fill: parent onClicked: { //rw.showtocinwebview(); hideicons() // hidetables() pgslider.visible = false } } }
Component.onCompleted: showicons()
}