一、新建QtGUI應用,基類選擇QDialog,取消建立界面函數
二、構造函數中:code
setWindowTitle("Custom Dialog"); QLabel *lbl = new QLabel("Name"); QLineEdit *edit = new QLineEdit(""); QPushButton *okbtn = new QPushButton("ok"); QPushButton *cancelbtn = new QPushButton("cancel"); QHBoxLayout *hlay1 = new QHBoxLayout(); hlay1->addWidget(lbl); hlay1->addWidget(edit); QHBoxLayout *hlay2 = new QHBoxLayout(); hlay2->addWidget(okbtn); hlay2->addWidget(cancelbtn); QVBoxLayout *vlay = new QVBoxLayout(); vlay->addLayout(hlay1); vlay->addLayout(hlay2); setLayout(vlay);
三、效果blog