scythargon
scythargon

Reputation: 3491

pyqt4: how to see QWebPage?

I am new at QT, found some code that do what I need (some web-browsing things), it uses QWebPage to get get pages, but it does not make windows to see it. I tried to use example from Russian wiki (it works):

import sys

from PyQt4.QtGui import *
application = QApplication(sys.argv)

widget = QWidget()

widget.resize(320, 240)
widget.setWindowTitle("Hello, World!")  
widget.show()

sys.exit(application.exec_()) 

And this points: QWebPage inherit QObject, QObject inherit QWidget

but for

browser = QWebPage()
browser.show()

I get AttributeError: 'QWebPage' object has no attribute 'show'

Upvotes: 1

Views: 671

Answers (1)

l4mpi
l4mpi

Reputation: 5149

QObject inherits QWidget

No, It doesn't - QWidget inherits QObject, not the other way around. QWebPage is just a data object. You need a QWebView which inherits QWidget and is the widget used for displaying QWebPages:

browser = QWebView()
browser.show()

Upvotes: 2

Related Questions