在槽函数中写入groupbox控件显示

void MAIN_UI::GroupCharge()  //充值缴费屏幕区
{
   gpMain->close();
   qDebug()<<"fwjojw";
   QPushButton *bt111= new QPushButton("jfiosj",this);
   gpCharge = new QGroupBox("主界面》充值缴费",this);
 
  
   QLabel *lbphonenum = new QLabel("请输入手机号");
   QLabel *lbsurenum = new QLabel("  确认手机号");
   QLabel *lbmoney = new QLabel("    充值金额");
   QLabel *lbkpwd = new QLabel("输入交易密码");
 
  
   QLineEdit *edtnum = new QLineEdit;
   QLineEdit *edtsnum= new QLineEdit;
   //QFormLayout *formLayout = new QFormLayout;
   QDoubleSpinBox *dpmoney = new QDoubleSpinBox;   // 双向加数框
   dpmoney->setRange(0.0, 360.0);
   //formLayout->addRow(new QLabel(tr("Angle: ")), dpmoney);
   QLineEdit *edtkpwd = new QLineEdit;
 
  
   QPushButton *btOk =new QPushButton("确定");
   QPushButton *btcanc =new QPushButton("取消");
 
  
   QVBoxLayout *vlab = new QVBoxLayout;
   vlab->addWidget(lbphonenum);
   vlab->addWidget(lbsurenum);
   vlab->addWidget(lbmoney);
   vlab->addWidget(lbkpwd);
   vlab->addWidget(btOk);
   QVBoxLayout *vledt = new QVBoxLayout;
   vledt->addWidget(edtnum);
   vledt->addWidget(edtsnum);
   vledt->addWidget(dpmoney);
   vledt->addWidget(edtkpwd);
   vledt->addWidget(btcanc);
 
  
   QHBoxLayout *vall = new QHBoxLayout;
   vall->addLayout(vlab);
   vall->addLayout(vledt);
 
  
   gpCharge->setGeometry(10,100,200,200);
   gpCharge->setLayout(vall);
   gpCharge->show();   ///   很重要的一点在槽函数中一定要show才能显示出来
}

你可能感兴趣的:(Qt学习)