c++ - How to reset QML WebView? -
looks. here simplest code: https://www.dropbox.com/s/ctdcgrk0eqgq3a3/webview_test.tar.gz
when start app see white window. click on window , see browser twitter. click again , browser hide , destroyed.
so, please login twitter, destroy browser clicking first window , create again clicking on first window. see left signed in. need browser every time opens without signed user (even if user checked "remember me" checkbox). how this? how reset browser initial state?
here main parts of project:
main.cpp
#include <qapplication> #include <qquickview> #include "container.h" int main(int argc, char *argv[]) { qapplication a(argc, argv); container c; c.start(); return a.exec(); }
container.cpp
#include "container.h" #include <qdebug> #include <qquickitem> #include <qqmlcontext> container::container(qobject *parent) : qobject(parent) { mainfile = new qquickview(); browserexists = false; } container::~container() { delete mainfile; } void container::start() { mainfile->setsource(qurl("qrc:/main.qml")); connect(mainfile->rootobject(), signal(click()), this, slot(mainfileclicked())); mainfile->show(); } void container::mainfileclicked() { if(!browserexists) { browser = new qquickview(); browser->setsource(qurl("qrc:/browser.qml")); browser->rootcontext()->setcontextproperty("address", "http://twitter.com"); browser->show(); browserexists = true; } else { browser->hide(); delete browser; browserexists = false; } }
main.qml
import qtquick 2.0 rectangle { width: 320 height: 240 signal click(); mousearea { anchors.fill: parent onclicked: { click() } } }
browser.qml
import qtquick 2.0 import qtwebkit 3.0 import qtwebkit.experimental 1.0 item { width: 640 height: 480 signal closewindow(); webview { anchors.fill: parent url: address experimental.preferences.privatebrowsingenabled: true } }
Comments
Post a Comment