[PyKDE] Re: tab creation or khtml part crashing

Marcos Dione mdione at grulic.org.ar
Mon Dec 18 05:44:42 GMT 2006


On Sun, Dec 17, 2006 at 11:04:18PM -0300, Marcos Dione wrote:
> On Sun, Dec 17, 2006 at 09:37:38PM -0300, Marcos Dione wrote:
> >     def openInNewTab (self, url, urlArgs):
> >         linkTab= QWidget(self.tabMaster)
> >         tabLayout= QVBoxLayout(linkTab,11,6)
>  >        htmlView= KHTMLPart (self.tabMaster) // modified this line also
> >         htmlView.openURL (url)
> >         newTab= KHTMLView (htmlView, linkTab)
> >         tabLayout.addWidget (newTab)
> >         self.tabMaster.addTab (linkTab, url.url ())
> > 
> >     self.tabMaster is the QTabWidget that contains the tabs. any hints
> > what could be wrong?

    answering myself: KHTMLPart takes parentWidget and a parent. just
pass a proper parent, like "self".

>     also, now tabs open and are shown correctly, except that no
> scrollbars are shown, so the content "dissapears" at the right and the
> bottom. any hints?

    answering myself, again: forget about KHTMLView altogether. the
problem was like this:

* QTabWidget.addTab() only accepts QWidgets. KHTMLPart is not.
* QVBoxLayout is not a QWidget, so create one and use it as the layout
  parent.
* QVBoxLayout is not a QWidget, so you cannot use it as a KHTMLPart 
  parentWidget. so, add the KHTMLView.

    all this got fixed using only a splitter. here's the final code:

tab= QSplitter (self.tabMaster)
htmlView= KHTMLPart (tab, None, self)
htmlView.openURL (url)
self.tabMaster.addTab (tab, url.url ())

    simpler, cleaner, makes me happier :)

-- 
(Not so) Random fortune:
I'm no longer the man I pretended to be.
	    -- http://www.unitedmedia.com/comics/arlonjanis/index.html




More information about the PyQt mailing list