I'm trying to understand how Qt is handling instantiating objects of its widgets which are using dynamic memory allocation in user defined classes.
In below you can see main.cpp and part of a user-defined class "Foo" which comes from Qt installation example projects.
As a newbie I know that whenever we allocated dynamic memory we have to see the delete
also somewhere in the code.The question is where is such delete
to delete the dynamic memory which is allocated in Foo.cpp in below line?
QChartView *mychart= new QChartView();
main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
Foo *myobj = new Foo();
window.setCentralWidget(myobj);
window.resize(900, 600);
window.show();
return a.exec();
}
Foo.cpp
Foo::Foo(QWidget *parent) :
QWidget(parent)
{
QChartView *mychart= new QChartView();
...