自定義QDialog
阿新 • • 發佈:2021-02-20
技術標籤:unity
1、新建QtGUI應用,基類選擇QDialog,取消建立介面
2、建構函式中:
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);
3、效果