Qt study notes (eight) - QLineEdit usage summary

Common member function:


1.void setClearButtonEnabled(bool); // Whether to set a clear button.
Clicking this empty button will automatically delete all the contents of the line edit box, similar to clear().

2.void setEchoMode(QLineEdit::EchoMode); //Set the display mode of the text in the line edit box .
The two display modes are the most commonly used modes. They are: QLineEdit::Normal, QLineEdit::Password. The default is QLineEdit::Normal.

3.void setAlignent(Qt ::Alignment flag); //Set the position of the text input.

4.void setValidator(QVaildator*); //Set the input validator. (very important!!) (The specific usage is in the next code implementation Will talk about).

5.void setPlaceText(QString); //Set the placeholder.

6.void setText(QString); //Set the text in the line edit box.

7.void setReadOnly(bool); //Set the edit box of this line to read-only mode and cannot edit it.

8.void setEnabled(bool); //Set whether to activate the line edit box, the effect is similar to 7 .

9.void setContextMenuPolicy(Qt::NoC ontextMenu). / / set the line does not appear in the edit box menu (password input must be used).

10.void setDragEnabled (bool); / / set the selected text in the line edit box can be Drag and drop, the default can not be dragged.

11.void setAcceptDrops (bool); / / Set the line edit box can be dragged in the text.

12.bool isModified (); / / judgment text Whether it has been modified.

13.void selectAll(); //Select all the text in the box.

14.QString displayText(); //Return the displayed text.

15.QString selectedText( //Return the selected text.

信号:


1.void cursorPositionChanged(int old, int new); //The cursor position changes to find the signal.

2. Void returnPressed(); //When the cursor is inside the line edit box, click Enter to send a signal.

3.void selectionChanged() //When the selected text changes, a signal is sent.

4. Void textChanged(const QString & text) //When the text changes, it signals.