views:

41

answers:

1

I want to build a flowcharting application in Qt to get some practice modeling GUI applications. All it has are draggable boxes and circles that can be connected with straight lines.

As this is my first GUI application, I am unsure how one typically designs such a project. Here are my two designs.

1) Build a bunch of model classes (Box, Circle, Line, etc) and associated views (e.g. BoxView, CircleView, etc). The model objects have properties like color, x, y, width, height. The view classes subclass Qt UI elements. Then there are controllers like BoxMoveController that receives mouse events from the UI and updates the box view and box model appropriately. Or perhaps it is better if the box view receives the event, updates itself, and then passes the event to the controller to update the model? Now, I create application logic for the flowcharting logic that works on the model (like connect lines to boxes). The UI updates itself accordingly by the model notifying the view objects when an update to the model occurs.

2) Forget about the model stuff and build a "view-centric" application. Build a bunch of classes (Box, Circle, Line, etc) that subclass Qt UI elements. Then build application logic for the flowcharting stuff on top of these classes.

Which is better? What would you do differently?

A: 

I would go with the graphics view framework.

Have a look at the DiagramScene example provided with Qt.

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

I'm sure it will give you a good idea on how to implement such an app the Qt-way.

Jérôme