Qt之QLineEdit
来源:互联网 发布:excel数据递增 编辑:程序博客网 时间:2024/05/17 07:55
QLineEdit
setMode() //设置文本编辑显示模式
enum EchoMode:
Normal //普通模式
NoEcho //不允许输入
Password //编辑及显示时为密码样式
PasswordEchoOnEdit //显示时为密码样式
setInputMask() // 设置输入掩码来限制输入字符
setValidator() // 为其设置验证器(validator)来验证输入
setCompleter() // 为其设置自动完成器
#include "widget.h"#include <QLabel>#include <QLineEdit>#include <QHBoxLayout>#include <QVBoxLayout>#include <QValidator>#include <QRegExp>#include <QCompleter>// QLineEdit// setMode() //设置文本编辑显示模式// enum EchoMode:// Normal //普通模式// NoEcho //不允许输入// Password //编辑及显示时为密码样式// PasswordEchoOnEdit //显示时为密码样式// setInputMask() // 设置输入掩码来限制输入字符// setValidator() // 为其设置验证器(validator)来验证输入// setCompleter() // 为其设置自动完成器QHBoxLayout* getlayout(QWidget*,QWidget*);Widget::Widget(QWidget *parent) : QWidget(parent){ resize(300,300); QLabel *la1 = new QLabel("显示模式:"); QLineEdit *ld1 = new QLineEdit; QLabel *la2 = new QLabel("输入掩码:"); QLineEdit *ld2 = new QLineEdit; QLabel *la3 = new QLabel("输入验证:"); QLineEdit *ld3 = new QLineEdit; QLabel *la4 = new QLabel("自动完成:"); QLineEdit *ld4 = new QLineEdit; QHBoxLayout *ret1 = getlayout(la1,ld1); QHBoxLayout *ret2 = getlayout(la2,ld2); QHBoxLayout *ret3 = getlayout(la3,ld3); QHBoxLayout *ret4 = getlayout(la4,ld4); QVBoxLayout *mainlayout = new QVBoxLayout; mainlayout->addLayout(ret1); mainlayout->addLayout(ret2); mainlayout->addLayout(ret3); mainlayout->addLayout(ret4); setLayout(mainlayout); //显示模式 ld1->setEchoMode(QLineEdit::PasswordEchoOnEdit); //输入掩码 ld2->setInputMask("D99999999D");//输入前后不能为0的十位数 //输入验证 QRegExp rgx("\\d{11}");//输入十一位数 运用正则表达式 QValidator *validator = new QRegExpValidator(rgx,this); ld3->setValidator(validator); //自动验证 QStringList words; words << "math" << "macro" << "monther"; QCompleter *completer = new QCompleter(words,this); completer->setCaseSensitivity(Qt::CaseInsensitive);//大小写不敏感 ld4->setCompleter(completer);}QHBoxLayout* getlayout(QWidget* w1,QWidget *w2){ QHBoxLayout *ret = new QHBoxLayout; ret->addStretch(); ret->addWidget(w1); ret->addSpacing(10); ret->addWidget(w2); ret->addStretch(); return ret;}
阅读全文
0 0
- Qt 之 QLineEdit
- qt 之 QLineEdit
- Qt之QLineEdit
- Qt之QLineEdit
- Qt 之 QLineEdit 和 QRegExp
- qt学习笔记之QLineEdit
- QT之qss教程-QLineEdit
- Qt学习之路之QLineEdit
- Qt之QLineEdit之透明设置
- QT--------QLineEdit
- Qt::QLineEdit
- QT 之 QLineEdit 类 的常用函数
- Qt之QLineEdit详解(附源码)
- Qt学习笔记之QLabel、QLineEdit控件
- topic5:Qt入门之常用qt控件认知之QLineEdit
- Qt入门之常用qt控件认知之QLineEdit
- Qt之QLineEdit之插入图标及位置设置
- Qt之中文显示(QMessageBox、QLineEdit右键菜单等)
- (搬运).net起步 (自定义 ASP.NET CreateUserWizard 控件1)
- 使用hexo+GitHub搭建自己的博客中遇到问题的解决方法及博客美化
- system("pause")
- C++11智能指针之weak_ptr
- 空间配置器
- Qt之QLineEdit
- Python的坑(7) -- 定义默认参数要牢记一点:默认参数必须指向不变对象!
- web开发第二天
- The Boost Graph Library(1)
- Netty5入门学习笔记004-使用Netty传输POJO对象
- 组装原有控件实现横向滚动的时间选择器,可滑动 点击,初始状态在指定位置
- 设计模式-单例模式之饿汉式-多线程
- js中时间戳转化为时间
- Linux wait/waitpid详解