Qt Flowchart Application Architecture

I want to create a flowchart application in Qt to get hands-on modeling of graphical applications. All he has are drag boxes and circles that can be connected with straight lines.

Since this is my first GUI application, I'm not sure how such a project is usually developed. Here are my two projects.

1) Create a bunch of model classes (Box, Circle, Line, etc.) and their associated views (e.g. BoxView, CircleView, etc.). Model objects have properties such as color, x, y, width, height. Subclasses of class classes of Qt UI elements. Then there are controllers, such as BoxMoveController, which receive mouse events from the user interface and accordingly update the view of the window and the box. Or is it better if the viewer receives the event, updates itself, and then passes the event to the controller to update the model? Now I am creating application logic for flowchart logic that works on a model (for example, connects strings to boxes). The user interface is updated accordingly by the model, notifying view objects when the model is updated.

2) Forget about the material of the model and create an application focused on the "presentation". Create a bunch of classes (Box, Circle, Line, etc.) that subclass the Qt UI elements. Then create application logic for the flowchart above these classes.

What's better? What would you do differently?

+3
source share
1 answer

I would go beyond the graphical representation .

Check out the DiagramScene example with Qt.

It is located in yours Qt examples folder/graphicsview/.

I am sure this will give you a good idea on how to implement such a Qt-way application.

+1
source

Source: https://habr.com/ru/post/1763837/


All Articles