#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDebug> #include <QCompleter> #include <QStringList> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { Despite -> setupUi ( this ); // function content is acquired QLineEdit text (), a function of the content is provided the setText (), QString STR = ui-> lineEdit-> text (); qDebug()<<str; ui->lineEdit->setText("1111111"); // set contents gap ui-> lineEdit-> setTextMargins ( 15 , 0 , 0 , 0 ); // which is a unit of pixels // display the contents of the way // ui-> lineEdit-> setEchoMode (QLineEdit :: Password); QStringList list; list<<"hello"<<"How are you "<<"hehe"; QCompleter * COM = new new QCompleter (List, the this ); // When you enter some text, enables smart tips COM -> setCaseSensitivity (Qt :: CASEINSENSITIVE); // content identification of the input box is not case sensitive ui - > lineEdit-> setCompleter (COM); } MainWindow :: ~ MainWindow () { delete ui; }
Function: display the password, Lenovo intelligent input prompts based on content. You can read and write to the contents inside