Organizing desktop application

Maurizio Berti maurizio.berti at gmail.com
Tue Apr 13 17:21:16 BST 2021


Your readings didn't answer because the question is pointless per se:

- PyQt is a binding to Qt, a C++ framework, which couldn't care less about
what you do with python files; you could even create programs directly from
the interactive shell.
- MVC is a *design* pattern, it has absolutely *nothing* to do with the
file structure of the project. While it's common practice to have those
parts in different "physical" paths, not only they can also be in separate
files while being in the same folder, but they could also be all contained
in a single script.
- The MVC pattern is a bit different from the "Qt point of view", due to
the way the library works. In general, they are much less separated than
some other frameworks, and it's common to have both the view and the
controller contained in the same object (a display object, a class that
inherits from QWidget or its subclasses). For data models it's even more
"strict": in substance, it is just "Model/View", as both the view and the
controller are actually combined in what are called "item views"
(QListView, QTableView, QTreeView, all of them being Qt widgets inheriting
from QAbstractItemView); both the view and controller parts are also
partially managed through what is called an "item delegate", which is
responsible of displaying the data of each model index in a (possibly)
human readable form, and providing appropriate editors whenever required,
while interfacing with the model when data is being committed. Qt even
provides higher level views (QListWidget, QTableWidget, QTreeWidget), which
provide only simple interfaces to the underlying model, both for the
programmer and the user.
- There is no preferred design, it only depends on your needs (and
experience). Even using MVC should never be mandatory, as *any* design
pattern has to be chosen depending on the software requirements, not
"because that's how it's done". And this is valid for almost any generic
and multipurpose framework/language.

I suggest you to take your time and read more about this topic:
https://doc.qt.io/qt-5/model-view-programming.html


Il giorno mar 13 apr 2021 alle ore 17:51 Rich Shepard <
rshepard at appl-ecosys.com> ha scritto:

> I'm starting to learn PyQt5 building a desktop application. Prior
> applications have used the MVC design: model, view, controller. Can I
> organize the project this way or do PyQt applications put all files in a
> single directory?
>
> My readings haven't answered this question and I want to start this project
> using the preferred organization/design.
>
> TIA,
>
> Rich
>


-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210413/19320392/attachment.htm>


More information about the PyQt mailing list