[PyKDE] Using QDataStream

James Emerton james at emdata.net
Wed Apr 6 18:08:19 BST 2005

You may be able to exploit the Qt properties system to retrieve the 
most interesting members.  (Provided that the parts interesting to you 
are actually properties.)

# Saving...
props = { }
for p in obj.metaClass().propertyNames( True ):
     props[ p ] = obj.property( p )

# Loading...
for p, v in props.iteritems():
     obj.setProperty( p, v )

Of course, this is all of the top of my head and before my coffee has 
had a chance to kick in.


On 5-Apr-05, at 5:39 PM, Eron Lloyd wrote:

> Hello again,
> Since pickle doesn't allow objects wrapping QObjects, I guess 
> QDataStream is
> the next best bet. I haven't found any good examples of it in action, 
> so was
> wondering if anyone has any suggestions. Basically I have a class that 
> acts
> as a data model, and I'd like to store it's members (both python and
> QObjects) as serialized files. I've been spoiled by pickle up 'til 
> now...
> Thanks,
> Eron
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
This is not my home; the cats just let me stay here.

More information about the PyQt mailing list