[PyKDE] KDE app template: Qt signal problem...

Jim Bublitz jbublitz at nwinternet.com
Tue Apr 26 22:15:11 BST 2005

On Tuesday 26 April 2005 11:25, Simon Edwards wrote:
> On Tuesday 26 April 2005 19:48, Jim Bublitz wrote:
> > On Tuesday 26 April 2005 06:00, Simon Edwards wrote:
> > > Hello,
> > >
> > > I'm having some trouble translating one of the kdevelop C++ application
> > > templates to Python. Setting up some signals from the HTML KPart to the
> > > application isn't working. Qt gives:
> > >
> > > QObject::connect: No such signal QWidget::signalChangeStatusbar(const
> > > QString&)
> > > QObject::connect:  (sender name:   'unnamed')
> > > QObject::connect:  (receiver name: 'unnamed')
> > > QObject::connect: No such signal QWidget::signalChangeCaption(const
> > > QString&) QObject::connect:  (sender name:   'unnamed')
> > > QObject::connect:  (receiver name: 'unnamed')
> > >
> > > The code is:
> > >
> > > QObject.connect(self._html, SIGNAL("setWindowCaption(const QString&)"),
> > > self.slotSetTitle)
> > > QObject.connect(self._html, SIGNAL("setStatusBarText(const QString&)"),
> > > self.slotOnURL)
> > >
> > > (self._html is a KParts::ReadOnlyPart object) All of the code is here:
> > >
> > > http://www.simonzone.com/software/python/kdeapp.tar.bz2
> > >
> > > ideas?
> >
> > I get a 404 error for the url ?? Can you just email the code?
> my bad, try again,
> BTW, I'm using:
> * SIP 4.0.1
> * PyQt (PyQt-x11-gpl-3.12)
> * PyKDE 3.11.1

In testapp.py, KParts want to reside in a KParts.MainWindow, not a 
KMainWindow.  That means you'd need to provide an argument to createGUI as 
well, which would be the part being displayed in the main window.

Also, self._html is a KParts.ReadOnlyPart, which doesn't offer the signals 
you're trying to connect to. You should be able specify the class type in the 
createReadOnlyPart call (rather than using the default), or else try sip.cast 
to cast it to the type that offers the signals you want (not sure what you're 
going for here).

You can also look at examples/pyKHTMLPart.py - it's just hardcoded to use a 
KHTMLPart and bypasses a lot of the KParts machinery.

The problem I've had with using KTrader is that it doesn't always return the 
particular part(s) you want to embed - I'm not that familiar with all of the 
details of using KTrader (obviously). I'd consider whether you want to embed 
an arbitrary part based on what's available or you really want just a 
KHTMLPart or KHTMLView every time - the latter being a lot simpler and more 
predictable. I'd start by a) looking at what KTrader is offering you; b) 
hardcoding one choice offered and getting that to work; c) work on the 
KTrader stuff til that works.

There was an earlier KParts example but it broke with some of the KDE version 
changes quite a while ago, and I haven't worked up a new example. To get it 
to work with the approach you're using, you need to pay attention to what 
type self._html is, as returned from createReadOnlyPart - I believe all of 
the "typecasting" machinery is in place in sip and PyKDE, but haven't tried 
it out in a while.

I'm a little fuzzy on the details at the moment (and my head is pretty stuffed 
up too, so thinking about this hurts more than usual),   but those are the 
major features I recall about getting something like this to work.


More information about the PyQt mailing list