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

List:       pykde
Subject:    [OT] Re: [PyKDE] Deleting a layout in PyQt as opposed to Qt...
From:       Hans-Peter Jansen <hpj () urpla ! net>
Date:       2007-02-28 12:38:26
Message-ID: 200702281338.26541.hpj () urpla ! net
[Download RAW message or body]

[Since this is essentially off topic, it's intentionally top posted!]

Hi Giovanni,

did I already told you, that I LOVE your contributions to this project and 
list! While nobody will be able to beat Phils S/N ratio ever, David Boddie 
and you are my personal PyQt heros.

Pete

Am Mittwoch, 28. Februar 2007 12:39 schrieb Giovanni Bajo:
> On 28/02/2007 12.17, Sundance wrote:
> > Am I missing something? Is this an oversight in PyQt, or is there a
> > nice, clean Python equivalent that I've overlooked?
>
> With recent versions of SIP, you can do:
>
> import sip
> sip.delete(widget.layout())
>
> =================
>
> Otherwise, if you're bound to an older version, a less clear but
> effective way is to force SIP to transfer ownership of the object back to
> Python. By doing so, you tie the lifetime of the C++ object to the
> lifetime of the Python object:
>
> import sip
> L = widget.layout()
> sip.transferback(L)
> del L   # drop last Python reference -> destroy C++ object
>
> Or, a more compact but equivalent form:
>
> import sip
> sip.transferback(widget.layout())
>
> Of course, for this to work, you need to make sure you don't have *any*
> other Python reference to that layout.
>
> =================
>
> A third solution involves the fact that QLayout is a QObject, so you can
> use its deleteLater() method:
>
> L = widget.layout()
> L.deleteLater()
> QCoreApplication.sendPostedEvents(L, QEvent.DeferredDelete)

_______________________________________________
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