How do i bind Class to QML window in Qt5 or is it a bug.
-
Hi
I create a QML window with
@void Check::createWindow(){
QDeclarativeView *decView= new QDeclarativeView();QObject::connect(decView->engine(), SIGNAL(quit()),decView, SLOT(deleteLater())); QString mUrl="http://www.google.com"; decView->engine()->rootContext()->setContextProperty("MyApp",this); decView->engine()->rootContext()->setContextProperty("mUrl",mUrl); decView->setSource(QUrl("qrc:/inc/getwebsite.qml")); decView->show();
}@
my slot (public slot)
@QString Check::getAndBlockSiteToCheck(){qDebug()<<"Getting site to check"; return QString("http://www.asdf.com");
}@
and qml file
@ import QtQuick 1.1
import QtWebKit 1.0
WebView {width:600 height:700 settings.javascriptEnabled: true settings.javascriptCanOpenWindows: true settings.developerExtrasEnabled : true settings.autoLoadImages: false javaScriptWindowObjects: QtObject { WebView.windowObjectName: "MyCom" function openNew(){ alert('old url '+webView.url); var nexturl=MyApp.getAndBlockBlogToCheck(); alert("next url is "+nexturl); webView.url=nexturl; } } id: webView objectName: "myWebView" url:mUrl onLoadFinished: {webView.evaluateJavaScript("window.setTimeout('window.MyCom.openNew()',5000);");} onAlert: console.log(message);
}@
It runs first website (google.com) but when it tries to go to new page i get "exited with code -1073741819" error.
I just installed newest Qt5 final.
Where do i make mistake? -
I was opening Check::createWindow() from another class without making instance of "Check".