QIntValidator可以限制QLineEdit的输入范围:
QIntValidator* IntValidator = new QIntValidator();IntValidator->setRange(-10,10); //设置范围ui->lineEdit->setValidator(IntValidator);ui->lineEdit->setPlaceholderText("请输入-10-10");//提示