You can use layouts:
Red border line is QHBoxLayout.
Drag and drop layout that you need from left panel with ui elements to form in Qt Designer (i renamed layout as mainLt). Then you will be able to write following code:
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
void Widget::keyPressEvent(QKeyEvent *)
{
ui->mainLt->removeWidget(ui->label);
ui->label->hide();
ui->mainLt->insertWidget(0, new QSpinBox());
}
This code replaces QLabel at left with QSpinBox. So when you show window it looks like:
then you press any key...
voila!
This small example is pretty buggy: two spin boxes appears because i use Alt+PrintScreen for take a screenshot, which means i pressed two buttons and pressEvent has invoked twice :) But i think you get it. Draw widgets and add them to layouts according your design. After your conditions became true, remove ones widgets and insert anothers.