[PyQt] Problems with deletion of widgets
Filip Gruszczyński
gruszczy at gmail.com
Tue Jan 13 21:53:37 GMT 2009
At the ceratain point of my app I do:
1 self.area.setWidget(self.sheet.accept(self))
This line is called during an event handler, so it of course informs
about not deleting object during an event handler. So I have written:
1 def refresh(self):
2 self.area.widget().deleteLater()
3 self.area.setWidget(self.sheet.accept(self))
and hoped it will be ok (previously was).
Unfortunately the problem with deleting objects during event handler
still happen. I am doing some drag&drop and when user performs it my
model changes and the whole gui is rebuilt based on this model.
Therefore the GUI inside the area (it's a scrolled area) is not needed
and can be removed. But it just fails to work and from time to time it
crashes (what obviously I cannot accept).
I believe that the widgets that don't want to be deleted during event
handler are one dragged and one that is being dropped (I put some
object names on them). But I have no idea how to postpone the deletion
- I just send a signal on drop and refresh the gui (rebuild it). I
tried keeping a reference to the old one:
1 self.__old = self.area.widget()
but this failed to work - everything is deleted anyways (something I
can't understand - Python shouldn'tt delete this, if there is a
reference).
So my final question is: how to stop the deletion using methods from
PyQt (delteLater obviously failed me - and I tried to call it on the
whole widget structure, calling it on all children) or maybe some
workaround on which I can refresh the GUI after all operations are
done.
--
Filip Gruszczyński
More information about the PyQt
mailing list