MVC with Python

Georg Altmann george at george-net.de
Tue Sep 16 12:54:47 CEST 2008


David Boddie schrieb:
> On Monday 15 September 2008 21:37, Georg Altmann wrote:
> 
>> I need some advice on how to implement model-view-controller. I am
>> trying to develop a GUI application with PyQt, yet the problem rather
>> applies to mvc in general, not just GUI applications.
>>
>> Let's say the data is a list of objects with a common base class. The
>> views are either a graphical representation of the objects or some form
>> of textual input. The views shall change the model by using command
>> objects (for undo, e.g. QUndoCommand).
> 
> [...]
> 
>> My problem is, how do the commands interact with the model?
> 
> One approach that combines the undo framework with the model/view framework
> is described here:
> 
>   http://doc.trolltech.com/qq/qq25-undo.html
> 
> The implementation is in C++, but it may be possible to pick up some
> useful tips from the article.

Thanks for the pointer. I studied the article before, but it doesn't 
seem to work for my problem:
If I understand the Qt model/view architecture correctly, data is always 
based on items which are wrapped into QVariant.
(see http://doc.trolltech.com/4.4/qabstractitemmodel.html#data)

So to use the Qt model/view architecture items have to be represented as 
a value. I think this leaves me with the problem of copying objects I 
described before.

Regards
Georg





More information about the Python-list mailing list