Qt中有lineEdit控件。有一种情况会导致C++中lineEdit的值设置无效。
QMessageBox msgBox;
msgBox.setText("Fail to deal with it !!");
msgBox.exec();
this->lineEdit->setValue( QVariant( 0 ) );
在键盘按下Tab键,会发现控件lineEdit的值没有发生变化。修改如下:
this->lineEdit->setValue( QVariant( 0 ) );
QMessageBox msgBox;
msgBox.setText("Fail to deal with it !!");
msgBox.exec();