Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to reset QQuickView and his QML file into initial state?
Forum Updated to NodeBB v4.3 + New Features

How to reset QQuickView and his QML file into initial state?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 954 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Robotex
    wrote on 4 Jun 2014, 13:59 last edited by
    #1

    Looks. Here is the simplest code: "https://www.dropbox.com/s/ctdcgrk0eqgq3a3/webview_test.tar.gz":https://www.dropbox.com/s/ctdcgrk0eqgq3a3/webview_test.tar.gz

    When you start this app you will see white window. Click on window and you will see browser with Twitter. Click again and browser will be hide and destroyed.

    So, please login to Twitter, than destroy browser by clicking first window and then create it again by clicking on first window. You will see that you left signed in. But I need that browser every time opens without signed user (even if user checked "Remember me" checkbox). How to do this? How to reset browser to the initial state?

    Here is 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&#40;&#41;;
    }@
    

    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
        }
    }@
    
    1 Reply Last reply
    0

    1/1

    4 Jun 2014, 13:59

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved