使用qt designer里面的layout添加控件比如:QPushButton *btn = new QPushButton("Button", this);ui->verticalLayout->addWidget(btn);