Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
ActiveQt and MVC pattern
redlars last edited by
How does model view controller pattern work with an ActiveQt containing a widget that will be hosted inside a .NET application?
The Widget definition looks like this;
class MyWidget : public QWidget, public QAxBindable
Q_PROPERTY(QString name READ name);
MyWidget( QWidget* parent = 0, Qt::WindowFlags f = 0 );
QString name() const;
This widget has been compiled\linked and embedded inside a .NET application. The .NET application creates and configures the MyWidget class inside the InitializeComponent method.
The mvc pattern defines three roles; view, model and controller. What role is the MyWidget class?
The MyWidget class could be a view since it derives from QWidget which is a base class for user interface objects. This leads to a few issues;
- The .NET application will create the MyWidget class. Who will create the controller and model object? The view or .NET application should not know or care about these items.
- The Widget might have multiple views. The .NET application should know about the Widget but not its views.
The MyWidget class could be a controller but it derives from QWidget which will display the user interface object. That means the controller is closely coupled to the view. Does not that go against the separation that mvc tries to accomplish?
One idea was to derive from QObject instead of QWidget but then the .NET application cannot insert the widget into a .NET form.
Appreciate any input.