Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Different QWebView objects produce identical output for same urls
Forum Updated to NodeBB v4.3 + New Features

Different QWebView objects produce identical output for same urls

Scheduled Pinned Locked Moved Qt WebKit
2 Posts 1 Posters 797 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.
  • V Offline
    V Offline
    veveve
    wrote on last edited by
    #1

    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()
    view.load(QUrl(url))
    def on_ready(ok):
    print(view.page().mainFrame().documentElement().toPlainText())
    view.loadFinished.connect(on_ready)

    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'
    load_and_print(url)
    load_and_print(url)
    
    app.exec_()
    
    # output:
    # 39
    # 39
    

    @

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

    1 Reply Last reply
    0
    • V Offline
      V Offline
      veveve
      wrote on last edited by
      #2

      Solution is to disable cache:

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

      1 Reply Last reply
      0

      • Login

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