当前位置:网站首页>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]+$")));
边栏推荐
- 公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?
- 项目管理到底管的是什么?
- How to use filters in jfinal to monitor Druid for SQL execution?
- Where can I find the computer device manager
- hot-fix、cherry-pick怎么提
- Architecture of IM integrated messaging system sharing 100000 TPS
- AtCoder Beginner Contest 255
- ESP8266 成为客户端和服务器
- Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
- 基于kubernetes平台微服务的部署
猜你喜欢
![[无线通信基础-13]:图解移动通信技术与应用发展-1-概述](/img/1d/62e55f1b5445d7349ec383879f4275.png)
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述

B_ QuRT_ User_ Guide(31)

深入解析 Apache BookKeeper 系列:第四篇—背压

Nansen double disk encryption giant self rescue: how to prevent the collapse of billions of dominoes

“飞桨+辨影相机”成为AI界的“预制菜”,工业AI质检落地更简单

Fastjson V2 简单使用手册

What if the taskbar is blank after win11 update? Solution to blank and stuck taskbar after win11 update

Ideal interface automation project

Redis的缓存穿透、缓存击穿和缓存雪崩

Doker的容器数据卷
随机推荐
How to develop the exchange system? Mature technology case of digital currency exchange system development
What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3
如何使用 DataAnt 监控 Apache APISIX
公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?
Meet the StreamNative | 杨子棵:是什么让我放弃了大厂 Offer
智慧路灯| 云计算点亮智慧城市的“星星之火”
微信小程序中的数据双向绑定
Redis的缓存穿透、缓存击穿和缓存雪崩
CTFSHOW权限维持篇
MIT doctoral dissertation optimization theory and machine learning practice
[golang] golang implements the string interception function substr
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述
有孚网络混合云,加速企业数字化转型升级
latex字母头顶两个点
深入解析 Apache BookKeeper 系列:第四篇—背压
机器学习编译入门课程学习笔记第二讲 张量程序抽象
RIDE:获取图片base64
手机上怎么开股票账户?另外,手机开户安全么?
[Android, kotlin, tflite] mobile device integration depth learning light model tflite (image classification)
latex中 & 号什么含义?