Hi,
I'm doing some refactoring. I'm implementing a Model-View-Controller pattern. The view is a Qt widget.
Originally, the Qt widget created a new instance of a QAbstractTableModel subclass on the heap. Lets call it FooTableModel.
e.g
Widget::Widget(QWidget* parent)
:
QWidget(parent)
m_model(new FooTableModel(this))
{
Should I create the new instance of FooTableModel in the MVC model instead?
By doing so, I could create a dependency on the view (assuming I still pass the widget's pointer to the FooTableModel constructor)
Alternatively, I could pass nothing to the FooTableModel constructor and manually delete the FooTableModel in my MVC model. *
The last option would be to leave the creation of the FooTableModel in the widget. (And let the widget handle the FooTableModel directly?)
Any suggestions, or preferences?
My guess is to go with * at the moment.