[PyQt] Question to the new style signals

Phil Thompson phil at riverbankcomputing.com
Sat Mar 19 15:50:18 GMT 2011


On Sat, 19 Mar 2011 16:10:41 +0100, Detlev Offenbach
<detlev at die-offenbachs.de> wrote:
> On Samstag, 19. März 2011, Phil Thompson wrote:
>> On Sat, 19 Mar 2011 14:27:11 +0100, Detlev Offenbach
>> 
>> <detlev at die-offenbachs.de> wrote:
>> > Hello,
>> > 
>> > I am using code like this to define new style signals in the classes
of
>> 
>> my
>> 
>> > application.
>> > 
>> > class foo(QObject):
>> >   signal1 = pyqtSignal(str)
>> > 
>> > class bar(foo):
>> >   signal1 = pyqtSignal((str,), (str, str))
>> > 
>> > Note, that class bar is "extending" the signal. When run with a debug
>> > version
>> > of Qt I get a message, that class bar is redefining signal
>> > signal1(QString)
>> > from it's parent class. How do I correctly extend signals?
>> 
>> What exactly is the message?
>> 
>> Phil
> 
> The message is like this:
> 
> QMetaObject::indexOfSignal: signal sourceFile(QString) from
> ProjectBaseBrowser 
> redefined in ProjectSourcesBrowser

It's a warning not an error to say that Qt, given the signature, can't
distinguish between the signal in foo from the one in bar. It's nothing to
do with PyQt, you'd get the same using C++.

If it were me I would define a bar.signal1 as (str, str) and used explicit
scopes where needed to pick between foo.signal1 and bar.signal1. However,
first thing I'd do is question (given the different number of arguments)
whether the two signals should have the same name in the first place.

Phil


More information about the PyQt mailing list