我在使用QMessageBox的时候出现的选择上的问题,创建了3个按键,在最后选择的时候用 if(clickedButton == ?)的时候,三个按键会被全部顺序执行,不知道是什么问题,来大侠指点,急盼回复!!
QMessageBox customMsgBox;
customMsgBox.setWindowTitle("Custom message box");
QPushButton *lockButton = customMsgBox.addButton(tr("lock"),QMessageBox::ActionRole);
QPushButton *unlockButton = customMsgBox.addButton(tr("Unlock"),QMessageBox::ActionRole);
QPushButton *cancelButton = customMsgBox.addButton(QMessageBox::Cancel);
customMsgBox.setIconPixmap(QPixmap("./456.jpg"));
customMsgBox.setText(tr("MAKE SURE THAT THE CARD IS THE ONE YOU WANT TO CHECK!"));
customMsgBox.exec();
if(customMsgBox.clickedButton() == lockButton);
label -> setText("Custom MessageBox /Lock");
if(customMsgBox.clickedButton() == unlockButton)
label -> setText("Custom MessageBox /Unlock");
if (customMsgBox.clickedButton() == cancelButton);
label -> setText("Custom MessageBox /Cancel");
每次执行完了以后都是只显示Cancel,Cout输出发现三个if都被执行了
[ 此帖被午小夜在2010-04-27 21:24重新编辑 ]