QButtonGroup

    QButtonGroup *buttonGroup=new QButtonGroup;
    buttonGroup->addButton( ui->pushButton, 1 );
    buttonGroup->addButton( ui->pushButton_2, 2 );
    connect(buttonGroup,SIGNAL(buttonClicked(int)),this,SLOT(buttonJudge(int)));
    void MainWindow::buttonJudge(int buttonID)
    {
 switch (buttonID)
       {
          case 1: ui->lineEdit->insert("1"); break;
          case 2: ui->lineEdit->insert("2"); break;
}
     }
 

你可能感兴趣的:(QButtonGroup)