Search code examples
qtwebkitpyqtqtwebkit

How to prevent QtWebkit load images?


I don't need images in the page loaded in QWebView. With a minimum example, how do I do it?:

import sys
from PyQt4 import QtCore, QtGui, QtWebKit

if __name__ == '__main__':

    app = QtGui.QApplication(sys.argv)
    w = QtWebKit.QWebView()
    url = QtCore.QUrl("http://www.google.com")
    w.load(url)
    w.show()

I only found this. However QtWebkit seems not work that way.


Solution

  • OK, I found QWebSettings::AutoLoadImages.

    So, basically:

    # before loading the url:
    st=w.settings()
    st.setAttribute(st.AutoLoadImages,False)
    

    would do the trick.