[PyQt] SIP and Q_PROPERTY

Phil Thompson phil at riverbankcomputing.com
Wed Mar 3 18:07:22 GMT 2010


On Wed, 03 Mar 2010 12:55:33 -0500, Josh <jknox at irobot.com> wrote:
> Hi,
> 
> I've been handed a Qt widget class (C++) that has several Q_PROPERTYs. 
> I'm working on the sip file to wrap the class but can't find any info 
> (in SIP docs or google) on how to wrap a Q_PROPERTY with SIP.
> 
> Is there a way to do this with SIP? Do I even need to? The Q_PROPERTYs' 
> getters & setters are members of the class anyways, so wrapping those 
> ought to provide the necessary functionality.

You can't/don't need to.

The fundamental problem is that in C++ property names and method names are
in different namespaces and so they can (and sometimes do) clash. In Python
they would be implemented in the same namespace (i.e. the class's
dictionary) hence the problem.

As a convenience you can use the QObject.pyqtConfigure() method to set any
number of properties at once using keyword arguments. You can also set them
when creating a new instance, again using keyword arguments.

Phil


More information about the PyQt mailing list