[PyQt] Overriding only one of two C++ virtual methods with different signature

Phil Thompson phil at riverbankcomputing.com
Sat Jan 19 19:21:10 GMT 2008

On Saturday 19 January 2008, Adeodato Simó wrote:
> Hello.
> I've subclassed in Python from a C++ class that has:
>   public slots:
>     virtual void updateSearch (const QString &pattern=QString());
>   protected:
>     virtual void updateSearch (QTreeWidget *treeWidget);
> I want to provide my own updateSearch(), but only for the slot case. Is
> this possible at all? At the moment, my python function is gettin called
> in both cases.
> Any help appreciated.

You need to handle both cases. Check the type of the argument to determine 
which one is called. For the one you aren't interested in, just call the base 

    def updateSearch(self, arg):
        if not isinstance(arg, QString):
            superclass.updateSearch(self, arg):


More information about the PyQt mailing list