Doubts about breaking Model View separation
-
If i have a Model like the following
class Model : public QAbstractListModel { private: QList<Base*> _data; public: //virtual functions of the base class : insertRow(), data(), etc... void insertObject(Base* ptr) { _data.push_back(ptr) }; };
where Base is the base class of a hierarchy :
class Base {}; class Derived1 : public Base {}; class Derived2 : public Base {};
Is it possible to call Derived1 constructor in a slot of a QWidget to create a new object to insert in model::_data?
Any help would be highly appreciated!Link to the repo with a working example (see AddDialog class)
-
If i have a Model like the following
class Model : public QAbstractListModel { private: QList<Base*> _data; public: //virtual functions of the base class : insertRow(), data(), etc... void insertObject(Base* ptr) { _data.push_back(ptr) }; };
where Base is the base class of a hierarchy :
class Base {}; class Derived1 : public Base {}; class Derived2 : public Base {};
Is it possible to call Derived1 constructor in a slot of a QWidget to create a new object to insert in model::_data?
Any help would be highly appreciated!Link to the repo with a working example (see AddDialog class)
@user13 said in Doubts about breaking Model View separation:
Is it possible to call Derived1 constructor in a slot of a QWidget to create a new object to insert in model::_data?
Sure, why not?
What is the problem?