label = new QLabel(this); label->setMinimumSize(150,60); label->setMaximumSize(240,30); label->setFont(QFont("Times",15,QFont::Black)); label->setText("press the button to\n" "turn on the buzzer"); label->setAlignment(AlignCenter);
flag = 0; //初始化为0,表示当前是停止状态的
b_on1 = new QPushButton("start",this); b_on1->setMinimumSize(30,20); b_on1->setFont(QFont("Times",15,QFont::Bold));
reset = new QPushButton("reset",this); reset->setMinimumSize(30,20); reset->setFont(QFont("Times",15,QFont::Bold));
QHBoxLayout * hbox2 = new QHBoxLayout(); hbox2->addWidget(b_on1); hbox2->addWidget(reset);
bAdd = new QPushButton("+",this); bAdd->setMinimumSize(20,20); bAdd->setFont(QFont("Times",15,QFont::Bold));
bSub = new QPushButton("-",this); bSub->setMinimumSize(20,20); bSub->setFont(QFont("Times",15,QFont::Bold));
edit = new QLineEdit(this); edit->setMinimumSize(20,40); edit->setText(QString("1"));
QVBoxLayout *vbox1 = new QVBoxLayout(); vbox1->addWidget(bAdd); vbox1->addWidget(bSub);
QHBoxLayout *hbox1 = new QHBoxLayout(); hbox1->addWidget(edit); hbox1->addLayout(vbox1);
QVBoxLayout *vbox = new QVBoxLayout(this); vbox->addWidget(label); vbox->addLayout(hbox1); vbox->addLayout(hbox2);