Re: Deleting widgets from PyQt4 QFormWidget

2010-09-16 Thread David Boddie
On Wednesday 15 September 2010 18:53, Andrew wrote:

> I'm trying to remove the widgets from the QFormLayout widget from
> PyQt4. According to the documentation I should be able to use the
> command .takeAt(int) which will delete the widget from the layout and
> then return to me the QLayoutWidget.

It will remove the widget from the layout but it won't delete it because
it doesn't own it. The widget will still remain within its parent widget.
You have to either reparent it to another widget, or delete it manually.

[...]

> Am I missing a step or is this just broken? I haven't been able to
> find anything else on this issue yet. If it's broke, is there any
> potential workaround?

Try calling deleteLater() on each widget when you take it from the layout.
Does that work?

David
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deleting widgets from PyQt4 QFormWidget

2010-09-15 Thread Andrew
On Sep 15, 9:53 am, Andrew  wrote:
> I'm trying to remove the widgets from the QFormLayout widget from
> PyQt4. According to the documentation I should be able to use the
> command .takeAt(int) which will delete the widget from the layout and
> then return to me the QLayoutWidget.
> It currently is giving me back the widget, but is not removing it from
> the layout.
> At the moment, I'm simply trying to clear out all the widgets on the
> layout with this:
>
> def clearForm(self):
>                 print ("Clearing")
>                 print self.dataForm.rowCount()
>                 for i in range(self.dataForm.rowCount()-1, -1, -1):
>                         print " .",
>                         tmp = self.dataForm.takeAt(i)
>                         print tmp.widget()
>                         tmp = ""
>                 print self.dataForm.rowCount()
>
> It goes through each widget on the layout, and prints out the
> classes .__repr__ on the tmp.widget() line since tmp is a
> QLayoutWidget. So it's doing the returning part, but they still exist
> instead of being deleted like the documentation explains.
>
> Am I missing a step or is this just broken? I haven't been able to
> find anything else on this issue yet. If it's broke, is there any
> potential workaround?
>
> I'm using python 2.6.4 and PyQt4 4.7.6
>
> Thanks,
> Andrew

QLayoutWidget, I meant a QWidgetItem.
-- 
http://mail.python.org/mailman/listinfo/python-list