Languages/Python/PyKDE WebKit Tutorial/Part4: Difference between revisions

From KDE TechBase
(update to new syntaxhighlighter)
(Mark for archiving)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Archived}}
{{Warning|This tutorial uses Qt4, PyQt4, and PyKDE4.}}
Now we want to prepare to add an address bar.
Now we want to prepare to add an address bar.


Replace the __init__ method with:
Replace the __init__ method with:


<syntaxhighlighter lang="python">
<syntaxhighlight lang="python">
         self.widget = QWidget()
         self.widget = QWidget()


Line 12: Line 15:
         layout.addWidget(self.web)
         layout.addWidget(self.web)
         self.widget.show()
         self.widget.show()
</syntaxhighlighter>
</syntaxhighlight>


Now instead of having the ''QWebView'' as our top widget we have a plain ''QWidget''.  This widget contains a layout which is not a visible widget but ensure child widgets are put in a sensible place.  It is a ''QVBoxLayout'' which will put widgets in a vertical colum.
Now instead of having the ''QWebView'' as our top widget we have a plain ''QWidget''.  This widget contains a layout which is not a visible widget but ensure child widgets are put in a sensible place.  It is a ''QVBoxLayout'' which will put widgets in a vertical colum.

Latest revision as of 14:03, 31 May 2019


This page has been archived
The information on this page is outdated or no longer in use but is kept for historical purposes. Please see the Category:Archives for similar pages.
Warning
This tutorial uses Qt4, PyQt4, and PyKDE4.


Now we want to prepare to add an address bar.

Replace the __init__ method with:

        self.widget = QWidget()

        layout = QVBoxLayout(self.widget)

        self.web = QWebView(self.widget)
        self.web.load(QUrl("http://kubuntu.org"))
        layout.addWidget(self.web)
        self.widget.show()

Now instead of having the QWebView as our top widget we have a plain QWidget. This widget contains a layout which is not a visible widget but ensure child widgets are put in a sensible place. It is a QVBoxLayout which will put widgets in a vertical colum.

See the full code.

This version will look the same as the previous.

« Back to Part 3 | On to Part 5 »