You can read some informations about Layout Management
in Qt here: http://doc.trolltech.com/4.6.2/layout.html
From your hierarchy it seems that the QWidget on the QMainWindow isn't in a layout which should be at the QMainWindow
But this code should work:
Code:
QMainWindow *mainWindow = new QMainWindow();
QWidget *centralWidget = 0;
QVBoxLayout *verticalLayout = 0;
QHBoxLayout *horizontalLayout = 0;
QLCDNumber *lcdNumber_2 = 0;
QLCDNumber *lcdNumber = 0;
QSlider *horizontalSlider = 0;
QSlider *horizontalSlider_2 = 0;
centralWidget = new QWidget(mainWindow);
verticalLayout = new QVBoxLayout(centralWidget);
horizontalLayout = new QHBoxLayout();
horizontalLayout->setSpacing(6);
lcdNumber_2 = new QLCDNumber(centralWidget);
horizontalLayout->addWidget(lcdNumber_2);
lcdNumber = new QLCDNumber(centralWidget);
horizontalLayout->addWidget(lcdNumber);
verticalLayout->addLayout(horizontalLayout);
horizontalSlider = new QSlider(centralWidget);
horizontalSlider->setOrientation(Qt::Horizontal);
verticalLayout->addWidget(horizontalSlider);
horizontalSlider_2 = new QSlider(centralWidget);
horizontalSlider_2->setOrientation(Qt::Horizontal);
verticalLayout->addWidget(horizontalSlider_2);
mainWindow->setCentralWidget(centralWidget);
Same is possible with the designer please klick on QMainWindow in QtDesigner or designer mode of Qt Creator menu: "Tools" -> "Form Editor" and then all "Lay Out ..." things. Same actions can be found at the toolbar in the designer mode of Qt Creator.