[PyKDE] ListViewItems and garbage collection
Jim Bublitz
jbublitz at nwinternet.com
Sun Jul 21 17:24:25 BST 2002
On 21-Jul-02 Neil Stevens wrote:
> How do I keep my KListViewItems and instances of classes derived
> from KListViewItem from being garbage collected?
If you're using a non-NULL parent (KListView or KListViewItem) in
the constructor, they shouldn't be garbage collected. That assumes
that there is a chain of ownership above the parent that continues
to remain in scope and doesn't get garbage collected. If the latter
isn't true, assigning the KListViewItems to a variable probably
still won't keep them from getting destroyed when the parent or
something above it goes out of scope.
Can you post a simple test example showing the problem?
Below is an example basically from some code I'm working on.
KListViewItem should work the same way. As long as the 'SomeView'
instance ('view') doesn't get garbage collected, the list view and
items should continue to exist as well.
class SomeView (QWidget):
def __init__ ( ... ):
...
self.ListView = QListView(self,'ListBox1')
...
def someMethod (self):
...
for thing in self.thingList:
QListViewItem (self.ListView, thing)
...
view = SomeView ( ... )
...
view.someMethod ()
Jim
More information about the PyQt
mailing list