QT+常用控件_Line Edit

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QDebug>
#include <QCompleter>
#include <QStringList>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    //QLineEdit  中  获取内容的函数是text(),  设置的内容的函数是setText() ,
    QString str = ui->lineEdit->text();
    qDebug()<<str;

    ui->lineEdit->setText("1111111");

    //设置内容的间隙
    ui->lineEdit->setTextMargins(15,0,0,0);//其是以像素点为单位

    //显示内容的方式
//    ui->lineEdit->setEchoMode(QLineEdit::Password);

    QStringList list;
    list<<"hello"<<"How are you "<<"hehe";
    QCompleter *com = new QCompleter(list,this);//当输入一些文字时,能够实现智能提示

    com ->setCaseSensitivity(Qt::CaseInsensitive);//对输入框中的内容识别不区分大小写

    ui->lineEdit->setCompleter(com);

}

MainWindow::~MainWindow()
{
    delete ui;
}

功能:密码的显示方式,依据输入的内容进行智能联想提示。可以对里面的内容进行    读取  和    写入

猜你喜欢

转载自www.cnblogs.com/doker/p/11032936.html
今日推荐