473,387 Members | 1,757 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,387 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 1020

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

Similar topics

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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.