lineEdit控件是QLineEdit类的对象;
可以实现以下功能:
#include<QDebug>
#include<QCompleter>
#include<QList>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);//当前这句话是designer,在这句话后面写代码
ui->myButton->setText("123");
//QLineEdit
QString str=ui->lineEdit->text();//获取内容
qDebug()<<str;
//设置内容
ui->lineEdit->setText("shenhang");
//设置内容显示间隙
ui->lineEdit->setTextMargins(15,0,0,0);
//设置内容显示方式
//ui->lineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);//F1可见是枚举类型的形参
//qDebug()<<int(QLineEdit::PasswordEchoOnEdit);
QStringList list;
list<<"hello"<<"How are you"<<"hi";//往list里面插入若干个字符串
QCompleter*com=new QCompleter(list,this);//F1查看QCompleter构造函数的重载
com->setCaseSensitivity(Qt::CaseInsensitive);//不区分大小写
ui->lineEdit->setCompleter(com);
}