当前位置:网站首页>Qt笔记(七十四)之QLineEdit指定输入类型
Qt笔记(七十四)之QLineEdit指定输入类型
2022-06-30 22:48:00 【我是黄同学】
一.前言
楼主在实际开发 ,遇到了文本框只能输入数字或者字母的情况,本来以为需要自己做事件过滤,没想到Qt已经提供了相关的接口,楼主于是整理记录分享一下
二.设置限制输入类型举例
1.只允许输入数字
ui->lineEdit->setValidator(new QIntValidator(ui->lineEdit_pid));
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
2.只允许输入字母
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z]+$")));
3.只允许输入字母和数字 不区分字母大小写
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
4.只允许输入大写字母
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("^[A-Z]+$")));
5.只允许输入小写字母
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("^[a-z]+$")));
6.只允许输入中文
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("[\u4e00-\u9fa5]+$")));
边栏推荐
- RIDE:获取图片base64
- latex字母头顶两个点
- Nansen double disk encryption giant self rescue: how to prevent the collapse of billions of dominoes
- How to use filters in jfinal to monitor Druid for SQL execution?
- HDFS centralized cache management
- The superficial understanding of the industrial Internet finally brought the development of the industrial Internet into the strange circle of the consumer Internet
- Deployment of microservices based on kubernetes platform
- 10 airbags are equipped as standard, and Chery arizer 8 has no dead corner for safety protection
- 微信支付WxPayPubHelper v3版 回调xml为空的原因
- “飞桨+辨影相机”成为AI界的“预制菜”,工业AI质检落地更简单
猜你喜欢
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
机器学习编译入门课程学习笔记第二讲 张量程序抽象
Label Contrastive Coding based Graph Neural Network for Graph Classification
Introduction to digital transformation solutions for enterprises going to sea
B_ QuRT_ User_ Guide(33)
Win11如何优化服务?Win11优化服务的方法
Redis的缓存穿透、缓存击穿和缓存雪崩
Web APIs comprehensive case -tab column switching - dark horse programmer
多線程經典案例
深入解析 Apache BookKeeper 系列:第四篇—背压
随机推荐
机器学习编译入门课程学习笔记第二讲 张量程序抽象
Ideal interface automation project
[golang] golang实现截取字符串函数SubStr
KubeVela 1.4:让应用交付更安全、上手更简单、过程更透明
Using Obsidian with Hugo, markdown's local editing software is seamlessly connected with online
Architecture of IM integrated messaging system sharing 100000 TPS
"More Ford, more China" saw through the clouds, and the orders of Changan Ford's flagship products exceeded 10000
[golang] golang implements the string interception function substr
Web APIs comprehensive case -tab column switching - dark horse programmer
MIT博士论文 | 优化理论与机器学习实践
多线程经典案例
pytorch 的Conv2d的详细解释
手机上怎么开股票账户?另外,手机开户安全么?
Braces on the left of latex braces in latex multiline formula
Cas classique multithreadé
Introduction to machine learning compilation course learning notes lesson 2 tensor program abstraction
[Android, kotlin, tflite] mobile device integration depth learning light model tflite (image classification)
How do I open a stock account on my mobile phone? In addition, is it safe to open a mobile account?
分享十万级TPS的IM即时通讯综合消息系统的架构
Online education program user login and registration