c++ Qt lineedit设置只能输入数字
#include <QApplication> #include <QLineEdit> #include <QIntValidator> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLineEdit lineEdit; QIntValidator *validator = new QIntValidator(0, 99999, &lineEdit); // 限制输入范围为0-99999 lineEdit.setValidator(validator); lineEdit.show(); return app.exec(); }
##
QQ 3087438119