QString str = ui.ll->text(); try { if (str == NULL) { throw 1; } else { throw 1.2; } } catch (int & e) //参数的类型要与throw中类型保持一致,才能捕捉到;加上&能捕捉到抛出的值 { if (e == 1) { ui.ll->setText("68 04 00 43 00 00 00"); } qDebug()<setText("1.2"); } qDebug()< setText("..."); }