> I am sorry, there is an error in the example code I sent. The las line of > testQWidgetFactory.py should have been: > > w.child( 'myCustomWidget1' ).pythonMethod() > > The behaviour is different on various PyQt/sip versions. The problem is > related to the deletion of the Python version of MyCustomWidget instance > which is local to MyWidgetFactory.createWidget(). If I keep a reference on > this widget (for example in a global variable), the link between the C++ > QWidget and its Python counterpart is never lost. > > Is it mandatory to always keep somewhere a Python reference on a QWidget > to be > able to get this Python object from pure C++ methods returning QWidget * ?
It depends on the circumstances - most of the time it's done automatically, but sometime you have to be explicit. It's related to ownership issues - look at the SIP documentation for sip.transferto() and sip.transferback(). Phil _______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
