Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVM pattern with PySide

I've been trying to find a way to implement MVVM with PySide but haven't been able to. I think that there should be a way to create Views from ViewModels with QItemEditorFactory, and to do data binding I think I can use QDataWidgetMapper.

Do you have any ideas on how MVVM may be implemented with Qt and PySide? Even if there are some resources in C++ I'll try to translate them to python.

Thanks.

like image 558
Jorge Vargas Avatar asked Jun 14 '12 22:06

Jorge Vargas


1 Answers

MVVM was a specialization of the MVP (Model-View-Presenter) pattern, and is not specifically unique to WPF, but was part of its inception. I think what you're trying to get at is an MVP to expose your domain model as a view into that domain.

If you want examples in c++, you can see this PDF. However, you can get the gist of it from a terse synopsis in manged c# below:

public class DomainView : IDomainView
{
    private IDomainPresenter domainPresenter = null;

    ///<summary>Constructor</summary>
    public DomainView()
    {
        domainPresenter = new ConcreteDomainPresenter(this);
    }
}

Also, I'm wondering you could use the abstract object notation to make passable generics (view models) from your model to your views. Basically, you'd need an intermediary function to flag the relevant parts to serialize.

like image 160
FlavorScape Avatar answered Sep 21 '22 05:09

FlavorScape