PDA

View Full Version : Basic Qt Application Design



bmarkev
8th September 2010, 18:17
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?

Urthas
9th September 2010, 04:38
You should look at the documentation for the Diagram Scene Example (http://doc.trolltech.com/4.3/graphicsview-diagramscene.html). It is launchable with the Demo tool under Graphics View as well.