void setupUi(QDialog *MyDialog){ ... hboxLayout = new QHBoxLayout(MyDialog); pushButton1 = new QPushButton(MyDialog); hboxLayout->addWidget(pushButton1); ...}