In GitLab by @mariusalexander on Apr 5, 2023, 09:45
Say I want to delete all children with type MyFancyObject. (MyFancyObject is a derived class of GtObject)
To archive this I have to use the following code snippet:
auto childs= findDirectChildren<MyFancyObject*>();
GtObjectList objects;
std::copy(std::cbegin(childs), std::cend(childs), std::back_inserter(objects));
gtDataModel->deleteFromModel(objects);
I have to cast the child objects into a QList<GtObject*>. IMO this should not be necessary, as the class MyFancyObject is already a subclass of GtObject. Idealy there should be a templated method that accepts any subclass of GtObject*. Furthermore it should not matter if the list is a QList, QVector or std::vector etc. It should use iterators.
In GitLab by @mariusalexander on Apr 5, 2023, 09:45
Say I want to delete all children with type
MyFancyObject
. (MyFancyObject
is a derived class ofGtObject
)To archive this I have to use the following code snippet:
I have to cast the child objects into a
QList<GtObject*>
. IMO this should not be necessary, as the classMyFancyObject
is already a subclass ofGtObject
. Idealy there should be a templated method that accepts any subclass ofGtObject*
. Furthermore it should not matter if the list is aQList
,QVector
orstd::vector
etc. It should use iterators.