当前位置:网站首页>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]+$")));
边栏推荐
- msf之ms17-010永恒之蓝漏洞
- Meet the StreamNative | 杨子棵:是什么让我放弃了大厂 Offer
- leetcode:104. 二叉树的最大深度
- HP 惠普笔记本电脑 禁用触摸板 在插入鼠标后
- 云游戏| 云计算推动游戏行业进入“新纪元”
- Apache server OpenSSL upgrade
- [Android, kotlin, tflite] mobile device integration depth learning light model tflite (image classification)
- latex字母头顶两个点
- 严格次小生成树
- JVM Part 21 of interview with big companies Q & A
猜你喜欢

多线程经典案例

基于kubernetes平台微服务的部署

Ride: get picture Base64

公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?

企业出海数字化转型解决方案介绍

微信小程序中的数据双向绑定

Online education program user login and registration
![[无线通信基础-13]:图解移动通信技术与应用发展-1-概述](/img/1d/62e55f1b5445d7349ec383879f4275.png)
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述

What if the taskbar is blank after win11 update? Solution to blank and stuck taskbar after win11 update
![[Android, kotlin, tflite] mobile device integration deep learning light model tflite (object detection)](/img/7e/3e6ebfb90a82249d934296a041ba21.png)
[Android, kotlin, tflite] mobile device integration deep learning light model tflite (object detection)
随机推荐
leetcode:104. 二叉树的最大深度
10 airbags are equipped as standard, and Chery arizer 8 has no dead corner for safety protection
100 important knowledge points that SQL must master: creating and manipulating tables
CesiumJS 2022^ 源码解读[6] - 三维模型(ModelExperimental)新架构
latex左侧大括号 latex中大括号多行公式
2022中国国潮发展新动向
2022-06-30: what does the following golang code output? A:0; B:2; C: Running error. package main import “fmt“ func main() { ints := make
QQmlApplicationEngine failed to load component qrc:/main. qml:-1 No such file or directory
Youfu network hybrid cloud accelerates enterprise digital transformation and upgrading
严格次小生成树
What does project management really manage?
Yolo target detection
Two dots on the top of the latex letter
"Team training competition" Shandong multi university training 3
B_ QuRT_ User_ Guide(34)
The Sandbox 正在 Polygon 网络上进行部署
[Android, kotlin, tflite] mobile device integration deep learning light model tflite (object detection)
latex字母头顶两个点
Fastjson V2 简单使用手册
Swift5.0 ----Swift FrameWork的创建及使用