I have a QT application with a window of OSG written in C++. I want to implement the app using MVC design. The application allows you to add markers to OSG model and it is using QT to edit the markers.
First, I want to make sure that I understand MVC right.
Model - it's just the data that the View need to view and the Controller change. It is just a struct or POCO.
Controller - is where all the logic of the app.
View - need to view the Model data and send output to the Controller. Am I right? Everybody is explaining MVC differently.
How I do MVC in C++:
Instead of using callback for input I use the controller with the interface like that:
class InputCallbacks {
public:
virtual void undo() = 0;
virtual void redo() = 0;
virtual void addMarker(Posstion postion) = 0;
virtual void removeMarker(Marker marker) = 0;
};
class Controller : InputCallbacks {
/// ...
};
class View {
public:
void addInputListener(InputCallbacks* controller)
{
contollers.add(controller);
// ...
}
void refresh(Model* model)
{
// ...
}
private:
List<InputCallbacks*> contollers;
// example of View input to Contoller
void onUserClickUndoButton()
{
for (auto contoller : contollers)
{
contoller.undo();
}
}
};
Is this MVC design? Or I should do one callback that gets the state class, that is an interface? What is the way to make an MVC design in C++?