lineEdit->setValidator(new QRegExpValidator(QRegExp("[0-9]+$"))); 转载于:https://www.cnblogs.com/xiongzai/p/3267117.html