QT5-control-QLineEdit-text input control, used to enter the password or something is good, you can do not move the cursor like Linux Login Oh, qt5 -- qlineedit-
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QLineEdit>#include <QLabel>class MainWindow : public QMainWindow{ Q_OBJECTpublic: MainWindow(QWidget *parent = 0); ~MainWindow(); QLineEdit* edit[10]; QLabel* label ;public slots: void textChanged(const QString& text);};#endif // MAINWINDOW_H
# Include "mainwindow. h "MainWindow: MainWindow (QWidget * parent): QMainWindow (parent) {this-> resize (400,400); this-> centralWidget (); int ypos = 30; for (int I = 0; I <5; I ++) {edit [I] = new QLineEdit ("world, bad", this ); edit [I]-> setGeometry (10, ypos, 40); ypos + = 50;} // set the display mode edit [1]-> setEchoMode (QLineEdit: Normal ); // consistent with the default type. edit [2]-> setEchoMode (QLineEdit: NoEcho); // hide the input text without changing the cursor position. edit [3]-> setEchoM Ode (QLineEdit: Password); // use * to represent the text edit [4]-> setEchoMode (QLineEdit: PasswordEchoOnEdit); // If the edited text is the same as the default text, show missing focus * label = new QLabel ("text box content:", this); label-> setGeometry (10,300,350, 30); connect (edit [0], SIGNAL (textChanged (QString), this, SLOT (textChanged (QString);} MainWindow ::~ MainWindow () {} void MainWindow: textChanged (const QString & text) {label-> setText ("text box content:" + text );}
#include "mainwindow.h"#include <QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();}