QDialog and Inheritance

This BaseDialog is set out using a vertical layout and there are 3 widgets present: a top widget containing a custom dialog title information, a bottom widget containing custom dialog buttons and a central widget which fills the remaining space on the form.

The central widget is where I need assistance.

What I want to achieve is this: I want to be able to inherit from this BaseDialog and be able to replace the contents of its central widget with the content of the derived dialog.

At the moment, if I create a new QDialog but derive it from my BaseDialog class, when I add things like QPushButton widgets to the form, at runtime if I'm not careful with placement, they will overlap the widgets which are part of BaseDialog.

Is there a convenient way for me to achieve this?

UPDATE

What I've done so far is this:

Added a protected member to the BaseDialog class, exposing the central widget as follows:

The derived class in its constructor, instead of calling ui->setupUi(this); it calls ui->setupUi(this->centralWidget()); and so far, it seems fine. The only thing that doesn't seem to work is the resizing of the BaseDialog to accomodate the derived dialogs size.

If the central widget and layout for this dialog was accessible to derived classes this would work. You would need to make sure that all subclass's of your basedialog can access this widget and layout (central widget and layout declared as protected and not private).

Doing it this way might be a bad idea. It requires your subclass's to know something about the parent in order to work. It might be better to create a unique central widget instead and only use one basedialog class. Just a thought.

@webzoid More or less, yes. If you know what size the dialog should have after the change you can always call resize() to set the expected size.
Going further I think that in theory you could compute expected size based on sizeHint() methods of the child items however I never did that personally.