[PyQt] Model/View, QTreeView, drag/drop and arbitrary objects

Scott Ballard scott at scottballard.net
Tue Mar 24 01:44:41 GMT 2009


Hi,

I'm trying to put together a QTreeView using the Model/View programming 
but using either the Python Object class or QObject class as the data. 
It seems that neither can be passed around as MIME/QDataStream data for 
the drag and drop functionality. This looks the be a limitation of the 
PyQt implementation and not of Qt itself. Would be great if the 
documentation explicitly mentioned that they didn't implement 
Q_DECLARE_METATYPE() functionality under QMetaType instead having dead 
links to the method.

The current implementation seems to only support a small subset of PyQt 
classes (QStringList and a couple others) These are no good for handling 
objects with a lot of custom attributes.

I'm wondering if anyone has successfully done this before and what the 
trick is? Do you have any example code? There was mention of supporting 
arbitrary Python objects and QDataStream in the PyQt roadmap but no 
mention of when it might be completed. I understand that it won't be 
included in PyQT 4.5.

I really hope that I am overlooking something as my application hinges 
around this. The model/view programming seems great for simple stuff but 
falls apart quickly for more high level uses. Someone must have figured 
this out before!?

Cheers,
-Scott Ballard


More information about the PyQt mailing list