473,385 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Re: MVC with Python

Maric Michaud schrieb:
Le Tuesday 16 September 2008 14:47:02 Marco Bizzarri, vous avez écrit :
>On Tue, Sep 16, 2008 at 1:26 PM, Georg Altmann <ge****@george-net.dewrote:
>>Marco Bizzarri schrieb:
On Mon, Sep 15, 2008 at 9:37 PM, Georg Altmann <ge****@george-net.de>
wrote:
But this implies all the objects in the list have to be instances of
QObject. I wonder if this is isn't a weird design, because for example
all value type classes in Qt don't derive from QObject, e.g. QString. My
list objects are not that simple (in terms of the data structure). So is
it ok to make them QObjects?
Did you take a look at this?

http://www.potu.com/man/doc.trolltec...ogramming.html

It seems to imply that you should use QtAbstractItemModel as a base
class for all your models. But since I'm not an expert about Qt, I
cannot really say.
Yes, I did. But as I explained in my previous message, the whole Qt
model-view framework doesn't seem fit any data which can not be handled
as QVariant and thus as a value type.
It is not about QT, it is about MVC. In MVC, code which implement the model
should be completely ignorant of the libraries used for gui, and the gui part
of the application shouldn't acces directly to your model logic. This why
there is a third layer which abstract the logic of your datas and provide
standard operation for the gui code. This third layer (Controllers), should
be as few as possible coupled to the specificities of the gui library (but
must be).

The quoted papers explain rather well how to do this with QT (apart they call
controllers "delegates").
Except they always handle simple data. I don't see how to get around the
QVariant limitatation. Also the data should be displayed in a graphical
manner (maybe a QGraphicsScene/QGraphicsView or mabye custom
QScrollArea). This also doesn't seem to go well with the standard Qt
approach.

I could imagine to implement the model without using any Qt then use
proxy classes derived from QObject as controllers.
For medium to big project, don't be afraid to divide your program in three
packages, one for the model, in which you must not have any reference to QT
API of some sort, one for the controllers, where you provide events and
methods to manipulate your model, one for gui, where you just build windows,
subscribe to controller's events and use their functions as callbacks for
your widgets.
As this is a small project for now, I think the controller layer is too
much work. As the project gets bigger it should be possible to switch to
a full mvc implementation if necessary. For now I will try to work with
a model that provides some signals by itself.

Regards
Georg

Sep 16 '08 #1
0 1019

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.