I have done as below and I am able to invoke.
Main.qml
ApplicationWindow {
title: qsTr("diacritech")
width: 1200
height: 800
visible: true
WebEngineView {
id: webview
url: "http://www.google.co.in"
anchors.fill: parent
}
}
WebEngineView.cpp
WebEngineView::WebEngineView()
{
QQmlEngine engine;
QQmlContext *objectContext = new QQmlContext(engine.rootContext());
objectContext->setContextProperty("we",this);
QQmlComponent component(&engine);
component.
loadUrl(QUrl("qrc:/main.qml"));
QObject *object
= component.
create(objectContext
);
}
main.cpp
int main(int argc, char *argv[])
{
WebEngineView *weView = new WebEngineView();
weView->show();
return app.exec();
}
Main.qml
ApplicationWindow {
title: qsTr("diacritech")
width: 1200
height: 800
visible: true
WebEngineView {
id: webview
url: "http://www.google.co.in"
anchors.fill: parent
}
}
WebEngineView.cpp
WebEngineView::WebEngineView()
{
QQmlEngine engine;
QQmlContext *objectContext = new QQmlContext(engine.rootContext());
objectContext->setContextProperty("we",this);
QQmlComponent component(&engine);
component.loadUrl(QUrl("qrc:/main.qml"));
QObject *object = component.create(objectContext);
}
main.cpp
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
WebEngineView *weView = new WebEngineView();
weView->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Here I get 2 windows, 1. WebEngienView() 2. QML -> WebEngineView
When I comment the webengineview.show() in main.cpp, I am getting only one window.
Is this the way, this is to be done?
Also I am including another components of another QML file (ReaderToolBar.qml). The tool bar is displayed but I am not able to capture the mouseclick events
Main.qml (included below component)
ReaderToolBar {
id: tb
width: parent.width
height: 50
anchors.top: parent.top
color: "transparent"
}
ReaderToolBar {
id: tb
width: parent.width
height: 50
anchors.top: parent.top
color: "transparent"
}
To copy to clipboard, switch view to plain text mode
Is there something I am missing, which enables to capture the mouse click events?
Bookmarks