[PyKDE] Deleting items from Canvas

Jim Bublitz jbublitz at nwinternet.com
Wed Jun 5 17:53:00 BST 2002

On 01-Jan-70 Moray Taylor wrote:
> I have a program that puts items onto a canvas, keeps a reference
> to it, and deletes the reference when I want to remove the item
> from the canvas. What I want to know is...
> A) Is this all I need to do?
> B) If not, what is the reccommended way of removing items from a
> canvas?

> The reason I ask, is that I run PyQT on SGI, Intel, and PowerPC,
> the results from the PowerPC version are very different to the
> Intel/SGI, I cannot get the items to remove themselves from the
> canvas on PPC, the code I use is *exactly* the same.

I'd assume in that case you don't have any stray references to the
Python object hanging around which can cause problems.
> I need to know if it's the PowerPC with the problem or otherwise.

When I've had problems using 'removeChild' on x86, I've used
something like:

  def removeWidget (self, w) #w is a QWidget/QObject descendant
      dummy = QWidget ()
      w.reparent (dummy, QPoint (0, 0))
      # when dummy goes out of scope, it gets garbage collected
      # along with all of it's children (and the corresponding
      # C++ objects get destroyed as well)

The way Qt handles the above is different than the way
'removeChild' followed by 'del w' would work.


More information about the PyQt mailing list