Different QWebView objects produce identical output for same urls

  • I found that if we load one url with different QWebView objects parallely, we will get identical output: only one of this QWebView will make real request. Here is example in PyQt:

    from PyQt5.QtCore import QUrl
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtWebKitWidgets import QWebView

    def load_and_print(url):
    view = QWebView()
    def on_ready(ok):

    if name == 'main':
    app = QApplication([])

    # This url outputs random number:
    url = 'https://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new'
    # output:
    # 39
    # 39


    How can we get "fair", unique output for each QWebView object, If url is the same?

  • Solution is to disable cache:

    @view.page().settings().setObjectCacheCapacities(0, 0, 0)@

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.