A
A
agent_22032021-05-16 14:13:39
Python
agent_2203, 2021-05-16 14:13:39

How to disconnect from page session in QWebView?

I have the following code:

def exec_func_qt(ip, port, user, password, proxy_numb):
    QNetworkProxy.setApplicationProxy(
        QNetworkProxy(
            QNetworkProxy.HttpProxy, 
            hostName=ip,
            port=port,
            user=user,
            password=password

        )
    )
    app = QApplication(sys.argv) 
    web = QWebView()

    web.load(QUrl("https://google.com/"))
    
    def callback_function():
        sleep(3)
        app.quit()

    def on_load_finished():
        t = Thread(target=callback_function)
        t.start()

    #web.show()
    web.loadFinished.connect(on_load_finished)

    app.exec_()


As you can see, when loading the page, I don’t have a disconnect from the page, because I didn’t understand how to do it, instead, I just create a thread and then the application closes, because if you put a delay in the same thread, the page simply stops loading , and after loading the page, I need to load js for a couple of seconds, I looked through all the documentaries (which are very few) on PyQT, but I didn’t find anything about this, maybe I don’t understand something, can you tell me how to do it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question