Used to it qt3 's friends are using qt4 There must be some discomfort , Including building the interface , The use of some classes , There are some differences , Generally speaking Qt4 In the programming way, the design is more reasonable , Because it makes the interface code and operation code complete “ quarantine ” open an account with , In this way, we can avoid the embarrassing situation that we will rewrite the operation code when we modify the interface and then compile .qt4 In addition to optimizing the interface settings , Some classes are also simplified . Like the original Qt3 above QButtonGroup class , stay qt4 Of designer It doesn't show up . Just keep the original qt3 Of ButtonGroup. Right? qt4 There's no one up there QButtonGroup What about the class , Of course not . stay qt4 Of assistant It's described above QButtonGroup When he said :“
QButtonGroup provides an abstract container into which button widgets can be
placed. It does not provide a visual representation of this container (see 
QGroupBox for a container widget), but instead manages the states of each of
the buttons in the group”. It is mentioned that QButtonGroup Provides a virtual container for placing key controls , But it's not a visual container . It means
QButtonGroup stay qt4 Becomes an abstract class . But you can also manage the buttons as before . The usage is as follows :

       The first is to declare a QButtonGroup Class :QButtonGroup *buttonGroup;

       Then allocate space to the pointer object in the initialization or constructor :buttonGroup = new QButtonGroup;

       And then you can use it addButton() Function to add the key you want to place :

            buttonGroup->addButton( ui.pushButton0, 0 );
            buttonGroup->addButton( ui.pushButton1, 1 );
            buttonGroup->addButton( ui.pushButton2, 2 );
             buttonGroup->addButton( ui.pushButton3, 3 );
            buttonGroup->addButton( ui.pushButton4, 4 );
            buttonGroup->addButton( ui.pushButton5, 5 );
            buttonGroup->addButton( ui.pushButton6, 6 );
           buttonGroup->addButton( ui.pushButton7, 7 );
            buttonGroup->addButton( ui.pushButton8, 8 );
             buttonGroup->addButton( ui.pushButton9, 9 );

     In this way, you can match the desired button with its corresponding one ID The numbers correspond , Every time you click a key QButtonGroup Metropolitan signal buttonClicked (int
ID) launch , By judgment ID The slot is connected to it , The key can be judged . for example :

        connect( buttonGroup, SIGNAL(buttonClicked (int)), this,
SLOT(buttonJudge(int)) );// Connecting signals and slots

Finally, it is OK to judge the key in the slot function . Of course, the slot function should be declared in advance .

void IPhone::buttonJudge(int buttonID)
{
    if((modeFlag == defaultMode) || (modeFlag == hangupMode) || (modeFlag ==
inputMode))
{
   resetFont(1);
   if(modeFlag != inputMode)
    ui.lineEdit->clear();
   modeFlag = inputMode;
   switch (buttonID)
   {
      case 0: ui.lineEdit->insert("0"); break;
      case 1: ui.lineEdit->insert("1"); break;
      case 2: ui.lineEdit->insert("2"); break;
      case 3: ui.lineEdit->insert("3"); break;
      case 4: ui.lineEdit->insert("4"); break;
      case 5: ui.lineEdit->insert("5"); break;
      case 6: ui.lineEdit->insert("6"); break;
      case 7: ui.lineEdit->insert("7"); break;
      case 8: ui.lineEdit->insert("8"); break;
      case 9: ui.lineEdit->insert("9"); break;
    case 10: ui.lineEdit->insert("."); break;
    case 11: ui.lineEdit->insert("#"); break;
    default: break;
   }
}
}

In this way, we can realize simple key discrimination .

Technology
©2019-2020 Toolsou All rights reserved,
vue Changes in data Interface not updated Python realization js And Django Front and back interaction in the background JavaSwing To achieve a simple Lianliankan games C# Making a simplified version of calculator elementui Shuttle box el-transfer Display list content text too long JVM summary Regression of dependent variable order categories (R language )【C#】 The realization of student achievement information management system use css Design a simple style html login interface C language --------- Tetris ( source code )