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-

Source: Internet
Author: User

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();}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.