?? qlineedit.3qt
字號:
.br.ti -1c.BI "QString \fBinputMask\fR - the validation input mask".br.ti -1c.BI "QString markedText - the text selected by the user. Use selectedText instead \fI(read " "only" ")\fR \fI(obsolete)\fR".br.ti -1c.BI "int \fBmaxLength\fR - the maximum permitted length of the text".br.ti -1c.BI "bool \fBmodified\fR - whether the line edit's contents has been modified by the user \fI(read " "only" ")\fR".br.ti -1c.BI "bool \fBreadOnly\fR - whether the line edit is read only".br.ti -1c.BI "bool \fBredoAvailable\fR - whether redo is available \fI(read " "only" ")\fR".br.ti -1c.BI "QString \fBselectedText\fR - the selected text \fI(read " "only" ")\fR".br.ti -1c.BI "QString \fBtext\fR - the line edit's text".br.ti -1c.BI "bool \fBundoAvailable\fR - whether undo is available \fI(read " "only" ")\fR".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBkeyPressEvent\fR ( QKeyEvent * e )".br.ti -1c.BI "virtual QPopupMenu * \fBcreatePopupMenu\fR ()".br.ti -1c.BI "void repaintArea ( int from, int to ) \fI(obsolete)\fR".br.in -1c.SH DESCRIPTIONThe QLineEdit widget is a one-line text editor..PPA line edit allows the user to enter and edit a single line of plain text with a useful collection of editing functions, including undo and redo, cut and paste, and drag and drop..PPBy changing the echoMode() of a line edit, it can also be used as a "write-only" field, for inputs such as passwords..PPThe length of the text can be constrained to maxLength(). The text can be arbitrarily constrained using a validator() or an inputMask(), or both..PPA related class is QTextEdit which allows multi-line, rich-text editing..PPYou can change the text with setText() or insert(). The text is retrieved with text(); the displayed text (which may be different, see EchoMode) is retrieved with displayText(). Text can be selected with setSelection() or selectAll(), and the selection can be cut(), copy()ied and paste()d. The text can be aligned with setAlignment()..PPWhen the text changes the textChanged() signal is emitted; when the Return or Enter key is pressed the returnPressed() signal is emitted. Note that if there is a validator set on the line edit, the returnPressed() signal will only be emitted if the validator returns \fCAcceptable\fR..PPBy default, QLineEdits have a frame as specified by the Windows and Motif style guides; you can turn it off by calling setFrame(FALSE)..PPThe default key bindings are described below. The line edit also provides a context menu (usually invoked by a right mouse click) that presents some of these editing options. <center>.nf.TSl - l. Keypress Action Left Arrow Moves the cursor one character to the left. Shift+Left Arrow Moves and selects text one character to the left. Right Arrow Moves the cursor one character to the right. Shift+Right Arrow Moves and selects text one character to the right. Home Moves the cursor to the beginning of the line. End Moves the cursor to the end of the line. Backspace Deletes the character to the left of the cursor. Ctrl+Backspace Deletes the word to the left of the cursor. Delete Deletes the character to the right of the cursor. Ctrl+Delete Deletes the word to the right of the cursor. Ctrl+A Moves the cursor to the beginning of the line. Ctrl+B Moves the cursor one character to the left. Ctrl+C Copies the selected text to the clipboard. (Windows also supports Ctrl+Insert for this operation.) Ctrl+D Deletes the character to the right of the cursor. Ctrl+E Moves the cursor to the end of the line. Ctrl+F Moves the cursor one character to the right. Ctrl+H Deletes the character to the left of the cursor. Ctrl+K Deletes to the end of the line. Ctrl+V Pastes the clipboard text into line edit. (Windows also supports Shift+Insert for this operation.) Ctrl+X Deletes the selected text and copies it to the clipboard. (Windows also supports Shift+Delete for this operation.) Ctrl+Z Undoes the last operation. Ctrl+Y.TE.fi</center>.PPAny other key sequence that represents a valid character, will cause the character to be inserted into the line edit..PP.ce 1.B "[Image Omitted]".PP.ce 1.B "[Image Omitted]".PPSee also QTextEdit, QLabel, QComboBox, GUI Design Handbook: Field, Entry, and Basic Widgets..SS "Member Type Documentation".SH "QLineEdit::EchoMode"This enum type describes how a line edit should display its contents..TP\fCQLineEdit::Normal\fR - Display characters as they are entered. This is the default..TP\fCQLineEdit::NoEcho\fR - Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret..TP\fCQLineEdit::Password\fR - Display asterisks instead of the characters actually entered..PPSee also echoMode and echoMode..SH MEMBER FUNCTION DOCUMENTATION.SH "QLineEdit::QLineEdit ( QWidget * parent, const char * name = 0 )"Constructs a line edit with no text..PPThe maximum text length is set to 32767 characters..PPThe \fIparent\fR and \fIname\fR arguments are sent to the QWidget constructor..PPSee also text and maxLength..SH "QLineEdit::QLineEdit ( const QString & contents, QWidget * parent, const char * name = 0 )"Constructs a line edit containing the text \fIcontents\fR..PPThe cursor position is set to the end of the line and the maximum text length to 32767 characters..PPThe \fIparent\fR and \fIname\fR arguments are sent to the QWidget constructor..PPSee also text and maxLength..SH "QLineEdit::QLineEdit ( const QString & contents, const QString & inputMask, QWidget * parent, const char * name = 0 )"Constructs a line edit with an input \fIinputMask\fR and the text \fIcontents\fR..PPThe cursor position is set to the end of the line and the maximum text length is set to the length of the mask (the number of mask characters and separators)..PPThe \fIparent\fR and \fIname\fR arguments are sent to the QWidget constructor..PPSee also setMask() and text..SH "QLineEdit::~QLineEdit ()"Destroys the line edit..SH "int QLineEdit::alignment () const"Returns the alignment of the line edit. See the "alignment" property for details..SH "void QLineEdit::backspace ()"If no text is selected, deletes the character to the left of the text cursor and moves the cursor one position to the left. If any text is selected, the cursor is moved to the beginning of the selected text and the selected text is deleted..PPSee also del()..SH "int QLineEdit::characterAt ( int xpos, QChar * chr ) const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..SH "void QLineEdit::clear ()\fC [virtual slot]\fR"Clears the contents of the line edit..SH "void QLineEdit::clearModified ()"Resets the modified flag to FALSE..PPSee also modified..SH "void QLineEdit::clearValidator ()\fC [virtual slot]\fR"This slot is equivalent to setValidator(0)..SH "void QLineEdit::copy () const\fC [virtual slot]\fR"Copies the selected text to the clipboard, if there is any, and if echoMode() is Normal..PPSee also cut() and paste()..SH "QPopupMenu * QLineEdit::createPopupMenu ()\fC [virtual protected]\fR"This function is called to create the popup menu which is shown when the user clicks on the line edit with the right mouse button. If you want to create a custom popup menu, reimplement this function and return the popup menu you create. The popup menu's ownership is transferred to the caller..SH "void QLineEdit::cursorBackward ( bool mark, int steps = 1 )"Moves the cursor back \fIsteps\fR characters. If \fImark\fR is TRUE each character moved over is added to the selection; if \fImark\fR is FALSE the selection is cleared..PPSee also cursorForward()..SH "void QLineEdit::cursorForward ( bool mark, int steps = 1 )"Moves the cursor forward \fIsteps\fR characters. If \fImark\fR is TRUE each character moved over is added to the selection; if \fImark\fR is FALSE the selection is cleared..PPSee also cursorBackward()..SH "void QLineEdit::cursorLeft ( bool mark, int steps = 1 )"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPFor compatibilty with older applications only. Use cursorBackward() instead..PPSee also cursorBackward()..SH "int QLineEdit::cursorPosition () const"Returns the current cursor position for this line edit. See the "cursorPosition" property for details..SH "void QLineEdit::cursorRight ( bool mark, int steps = 1 )"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPUse cursorForward() instead..PPSee also cursorForward()..SH "void QLineEdit::cursorWordBackward ( bool mark )"Moves the cursor one word backward. If \fImark\fR is TRUE, the word is also selected..PPSee also cursorWordForward()..SH "void QLineEdit::cursorWordForward ( bool mark )"Moves the cursor one word forward. If \fImark\fR is TRUE, the word is also selected..PPSee also cursorWordBackward()..SH "void QLineEdit::cut ()\fC [virtual slot]\fR"Copies the selected text to the clipboard and deletes it, if there is any, and if echoMode() is Normal..PPIf the current validator disallows deleting the selected text, cut() will copy without deleting..PPSee also copy(), paste(), and setValidator()..SH "void QLineEdit::del ()"If no text is selected, deletes the character to the right of the text cursor. If any text is selected, the cursor is moved to the beginning of the selected text and the selected text is deleted..PPSee also backspace()..SH "void QLineEdit::deselect ()\fC [virtual slot]\fR"Deselects any selected text..PPSee also setSelection() and selectAll()..SH "QString QLineEdit::displayText () const"Returns the displayed text. See the "displayText" property for details..SH "bool QLineEdit::dragEnabled () const"Returns TRUE if the lineedit starts a drag if the user presses and moves the mouse on some selected text; otherwise returns FALSE. See the "dragEnabled" property for details..SH "EchoMode QLineEdit::echoMode () const"Returns the line edit's echo mode. See the "echoMode" property for details..SH "bool QLineEdit::edited () const"Returns TRUE if the line edit has been edited. Use modified instead; otherwise returns FALSE. See the "edited" property for details..SH "void QLineEdit::end ( bool mark )"Moves the text cursor to the end of the line unless it is already there. If \fImark\fR is TRUE, text is selected towards the last position; otherwise, any selected text is unselected if the cursor is moved..PPSee also home()..SH "bool QLineEdit::frame () const"Returns TRUE if the line edit draws itself with a frame; otherwise returns FALSE. See the "frame" property for details..SH "bool QLineEdit::getSelection ( int * start, int * end )"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code. use selectedText(), selectionStart().SH "bool QLineEdit::hasAcceptableInput () const"Returns TRUE if the input satisfies the inputMask and the validator; otherwise returns FALSE. See the "acceptableInput" property for details..SH "bool QLineEdit::hasMarkedText () const"Returns TRUE if part of the text has been selected by the user. Use hasSelectedText instead; otherwise returns FALSE. See the "hasMarkedText" property for details..SH "bool QLineEdit::hasSelectedText () const"Returns TRUE if there is any text selected; otherwise returns FALSE. See the "hasSelectedText" property for details..SH "void QLineEdit::home ( bool mark )"Moves the text cursor to the beginning of the line unless it is already there. If \fImark\fR is TRUE, text is selected towards the first position; otherwise, any selected text is unselected if the cursor is moved..PPSee also end()..SH "QString QLineEdit::inputMask () const"Returns the validation input mask. See the "inputMask" property for details..SH "void QLineEdit::insert ( const QString & newText )\fC [virtual slot]\fR"Deletes any selected text, inserts \fInewText\fR, and validates the result. If it is valid, it sets it as the new contents of the line edit..SH "bool QLineEdit::isModified () const"Returns TRUE if the line edit's contents has been modified by the user; otherwise returns FALSE. See the "modified" property for details..SH "bool QLineEdit::isReadOnly () const"Returns TRUE if the line edit is read only; otherwise returns FALSE. See the "readOnly" property for details..SH "bool QLineEdit::isRedoAvailable () const"Returns TRUE if redo is available; otherwise returns FALSE. See the "redoAvailable" property for details..SH "bool QLineEdit::isUndoAvailable () const"Returns TRUE if undo is available; otherwise returns FALSE. See the "undoAvailable" property for details..SH "void QLineEdit::keyPressEvent ( QKeyEvent * e )\fC [virtual protected]\fR"Converts key press event \fIe\fR into a line edit action..PPIf Return or Enter is pressed and the current text is valid (or can be made valid by the validator), the signal returnPressed() is emitted..PPThe default key bindings are listed in the detailed description..PPReimplemented from QWidget..SH "void QLineEdit::lostFocus ()\fC [signal]\fR"This signal is emitted when the line edit has lost focus..PPSee also focus, QWidget::focusInEvent(), and QWidget::focusOutEvent()..SH "QString QLineEdit::markedText () const"Returns the text selected by the user. Use selectedText instead. See the "markedText" property for details..SH "int QLineEdit::maxLength () const"Returns the maximum permitted length of the text. See the "maxLength" property for details..SH "QSize QLineEdit::minimumSizeHint () const\fC [virtual]\fR"Returns a minimum size for the line edit..PPThe width returned is enough for at least one character..PPReimplemented from QWidget..SH "void QLineEdit::paste ()\fC [virtual slot]\fR"Inserts the clipboard's text at the cursor position, deleting any selected text, providing the line edit is not read-only..PPIf the end result would not be acceptable to the current validator, nothing happens..PPSee also copy() and cut()..SH "void QLineEdit::redo ()\fC [virtual slot]\fR"Redoes the last operation if redo is available..SH "void QLineEdit::repaintArea ( int from, int to )\fC [protected]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPRepaints all characters from \fIfrom\fR to \fIto\fR. If cursorPos is between from and to, ensures that cursorPos is visible..SH "void QLineEdit::returnPressed ()\fC [signal]\fR"This signal is emitted when the Return or Enter key is pressed. Note that if there is a validator() or inputMask() set on the line edit, the returnPressed() signal will only be emitted if the input follows the inputMask() and the validator() returns \fCAcceptable\fR..PPExample: popup/popup.cpp..SH "void QLineEdit::selectAll ()\fC [virtual slot]\fR"Selects all the text (i.e. highlights it) and moves the cursor to the end. This is useful when a default value has been inserted because if the user types before clicking on the widget, the selected text will be deleted..PPSee also setSelection() and deselect().
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -