[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] QWidgetFactory and classes defined in Python
From:       "Phil Thompson" <phil () riverbankcomputing ! co ! uk>
Date:       2005-10-06 7:21:42
Message-ID: 14768.194.203.13.71.1128583302.squirrel () river-bank ! demon ! co ! uk
[Download RAW message or body]

> 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    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic