Saturday, April 18, 2009

Single inheritance with explicit deletion

In my last post, I adopted The Single Inheritance Approach. But for years, The Multiple Inheritance Approach has been recommended in Qt's way. Why not?

Its keyword : "explicit deletion"! See my last post again, and in fact, it was written with explicit deletion to the UI form instance.

samplewidget.cpp
#include "samplewidget.h"
#include "ui_samplewidget.h"

SampleWidget::SampleWidget(QWidget *parent)
: QWidget(parent), ui(new Ui::SampleWidgetClass)
{
ui->setupUi(this);
}

SampleWidget::~SampleWidget()
{
delete ui;
}

A reason of these approach is the scalability. For more detail, read the thread archives of QtCreator's mail list, title : "[Qt-creator] Multiple Iheritance".

No comments:

Post a Comment