#ifndef DIALOG_H #define DIALOG_H #include <QDialog> #include "QHBoxLayout" #include "QVBoxLayout" #include "QCheckBox" #include "QRadioButton" #include "QPlainTextEdit" #include "QPushButton" class Dialog : public QDialog { Q_OBJECT public: Dialog(QWidget *parent = nullptr); ~Dialog(); private: QCheckBox *cheBoxUnder; }; #endif // DIALOG_H
#include "dialog.h" Dialog::Dialog(QWidget *parent) : QDialog(parent) { cheBoxUnder = new QCheckBox("点击关闭"); QHBoxLayout* HLayl = new QHBoxLayout(); HLayl->addWidget(cheBoxUnder); setLayout(HLayl); connect(cheBoxUnder,SIGNAL(clicked(bool)),this,SLOT(close())); } Dialog::~Dialog() {}