class MyWidget : public QWidget { public: MyWidget( QWidget *parent=0, const char *name=0 ); };
MyWidget::MyWidget( QWidget *parent, const char *name )
: QWidget( parent, name ) {
QPushButton *quit = new QPushButton( "Quit", this, "quit" );
quit->setGeometry( 62, 40, 75, 30 );
quit->setFont( QFont( "Times", 18, QFont::Bold ) );
}
In the above code
quit
is allocated in Heap and it is necessary since it is child of MyWidget
Why does Qt needs allocate of child objects in the Heap?