📄 qlineedit.3qt
字号:
See 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 ()"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 ()"Deletes the character to the left of the text cursor and moves the cursor one position to the left. If any text has been selected by the user (e.g. by clicking and dragging), the cursor will be put at the beginning of the selected text and the selected text will be removed..PPSee also del()..SH "int QLineEdit::characterAt ( int xpos, QChar * chr ) const"Returns the index position of the character which is at \fIxpos\fR (in logical coordinates from the left). If \fIchr\fR is not 0, \fC*<em>chr</em>\fR is populated with the character at this position..SH "void QLineEdit::clear ()\fC [virtual slot]\fR"Syntactic sugar for setText( "" ), provided to match no-argument signals..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 lineedit 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 it but not delete it..PPSee also copy() and paste()..SH "void QLineEdit::del ()"Deletes the character on the right side of the text cursor. If any text has been selected by the user (e.g. by clicking and dragging), the cursor will be put at the beginning of the selected text and the selected text will be removed..PPSee also backspace()..SH "void QLineEdit::deselect ()\fC [virtual slot]\fR"De-selects all text (i.e. removes highlighting) and leaves the cursor at the current position..PPSee also setSelection() and selectAll()..SH "QString QLineEdit::displayText () const"Returns the text that is displayed. 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 echo mode of the line edit. See the "echoMode" property for details..SH "bool QLineEdit::edited () const"Returns the edited flag of the line edit. See the "edited" property for details..SH "void QLineEdit::end ( bool mark )"Moves the text cursor to the end of the line. 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 )"This function sets \fC*<em>start</em>\fR to the position in the text where the selection starts and \fC*<em>end</em>\fR to the position where the selection ends. Returns TRUE if \fIstart\fR and \fIend\fR are not null and if there is some selected text; otherwise returns FALSE..PPSee also setSelection()..SH "bool QLineEdit::hasMarkedText () const"Returns TRUE if part of the text has been selected by the user (e.g. by clicking and dragging); 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. 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 "void QLineEdit::insert ( const QString & newText )\fC [virtual slot]\fR"Removes 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::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 "QString QLineEdit::markedText () const"Returns the text selected by the user (e.g. by clicking and dragging), or QString::null if no text is selected. See the "markedText" property for details..SH "int QLineEdit::maxLength () const"Returns the maximum permitted length of the text in the editor. 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..PPIf the end result is not acceptable for the current validator, nothing happens..PPSee also copy() and cut()..SH "void QLineEdit::redo ()\fC [virtual slot]\fR"Redoes the last operation.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..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 erased..PPSee also setSelection() and deselect()..SH "QString QLineEdit::selectedText () const"Returns any text selected by the user or QString::null. See the "selectedText" property for details..SH "void QLineEdit::selectionChanged ()\fC [signal]\fR"This signal is emitted whenever the selection changes..PPSee also hasSelectedText and selectedText..SH "void QLineEdit::setAlignment ( int flag )\fC [virtual slot]\fR"Sets the alignment of the line edit to \fIflag\fR. See the "alignment" property for details..SH "void QLineEdit::setCursorPosition ( int )\fC [virtual slot]\fR"Sets the current cursor position for this line edit. See the "cursorPosition" property for details..SH "void QLineEdit::setDragEnabled ( bool b )\fC [virtual slot]\fR"Sets whether the lineedit starts a drag if the user presses and moves the mouse on some selected text to \fIb\fR. See the "dragEnabled" property for details..SH "void QLineEdit::setEchoMode ( EchoMode )\fC [virtual slot]\fR"Sets the echo mode of the line edit. See the "echoMode" property for details..SH "void QLineEdit::setEdited ( bool )"Sets the edited flag of the line edit. See the "edited" property for details..SH "void QLineEdit::setFrame ( bool )\fC [virtual slot]\fR"Sets whether the line edit draws itself with a frame. See the "frame" property for details..SH "void QLineEdit::setMaxLength ( int )\fC [virtual slot]\fR"Sets the maximum permitted length of the text in the editor. See the "maxLength" property for details..SH "void QLineEdit::setReadOnly ( bool )\fC [virtual slot]\fR"Sets whether the line edit is read only. See the "readOnly" property for details..SH "void QLineEdit::setSelection ( int start, int length )\fC [virtual slot]\fR"Sets the selected area of this line edit to start at position \fIstart\fR and be \fIlength\fR characters long..PPSee also deselect(), selectAll() and getSelection()..SH "void QLineEdit::setText ( const QString & )\fC [virtual slot]\fR"Sets the text in the line. See the "text" property for details..SH "void QLineEdit::setValidator ( const QValidator * v )\fC [virtual slot]\fR"Sets this line edit to accept input only as accepted by the validator, \fIv\fR, allowing arbitrary constraints on the text which may be entered..PPIf \fIv\fR == 0, setValidator() removes the current input validator. The initial setting is to have no input validator (i.e. any input is accepted up to maxLength())..PPSee also validator() and QValidator..PPExamples:.)l lineedits/lineedits.cpp and wizard/wizard.cpp..SH "QSize QLineEdit::sizeHint () const\fC [virtual]\fR"Returns a recommended size for the widget..PPThe width returned, in pixels, is usually enough for about 15 to 20 characters..PPExample: addressbook/centralwidget.cpp..SH "QString QLineEdit::text () const"Returns the text in the line. See the "text" property for details..SH "void QLineEdit::textChanged ( const QString & )\fC [signal]\fR"This signal is emitted whenever the text changes. The argument is the new text..PPExamples:.)l wizard/wizard.cpp and xform/xform.cpp..SH "void QLineEdit::undo ()\fC [virtual slot]\fR"Undoes the last operation.SH "bool QLineEdit::validateAndSet ( const QString & newText, int newPos, int newMarkAnchor, int newMarkDrag )"Validates and perhaps sets this line edit to contain \fInewText\fR with the cursor at position \fInewPos\fR, with selected text from \fInewMarkAnchor\fR to \fInewMarkDrag\fR. Returns TRUE if it changes the line edit; otherwise returns FALSE..PPLinebreaks in \fInewText\fR are converted to spaces, and the text is truncated to maxLength() before its validity is tested..PPRepaints and emits textChanged() if appropriate..SH "const QValidator * QLineEdit::validator () const"Returns a pointer to the current input validator, or 0 if no validator has been set..PPSee also setValidator()..PPExample: wizard/wizard.cpp..SS "Property Documentation".SH "Alignment alignment"This property holds the alignment of the line edit..PPPossible Values are Qt::AlignAuto, Qt::AlignLeft, Qt::AlignRight and Qt::AlignHCenter..PPAttempting to set the alignment to an illegal flag combination does nothing..PPSee also Qt::AlignmentFlags..PPSet this property's value with setAlignment() and get this property's value with alignment()..SH "int cursorPosition"This property holds the current cursor position for this line edit..PPSetting the cursor position causes a repaint when appropriate..PPSet this property's value with setCursorPosition() and get this property's value with cursorPosition()..SH "QString displayText"This property holds the text that is displayed..PPIf EchoMode is Normal this returns the same as text(); if EchoMode is Password it returns a string of asterisks the text().length() characters long, e.g. "******"; if EchoMode is NoEcho returns an empty string, ""..PPSee also echoMode, text and EchoMode..PPGet this property's value with displayText()..SH "bool dragEnabled"This property holds whether the lineedit starts a drag if the user presses and moves the mouse on some selected text..PPSet this property's value with setDragEnabled() and get this property's value with dragEnabled()..SH "EchoMode echoMode"This property holds the echo mode of the line edit..PPThe initial setting is Normal, but QLineEdit also supports NoEcho and Password modes..PPThe widget's display and the ability to copy or drag the text is affected by this setting..PPSee also EchoMode and displayText..PPSet this property's value with setEchoMode() and get this property's value with echoMode()..SH "bool edited"This property holds the edited flag of the line edit..PPThe edited flag is never read by QLineEdit; it has a default value of FALSE and is changed to TRUE whenever the user changes the line edit's contents..PPThis is useful for things that need to provide a default value but cannot find the default at once. Just start the line edit without the best default; when the default is known, check the edited() return value and set the line edit's contents if the user has not started editing the line edit..PPCalling setText() resets the edited flag to FALSE..PPSet this property's value with setEdited() and get this property's value with edited()..SH "bool frame"This property holds whether the line edit draws itself with a frame..PPIf enabled (the default) the line edit draws itself inside a two-pixel frame, otherwise the line edit draws itself without any frame..PPSet this property's value with setFrame() and get this property's value with frame()..SH "bool hasMarkedText"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis property holds whether part of the text has been selected by the user (e.g. by clicking and dragging)..PPGet this property's value with hasMarkedText()..PPSee also selectedText..SH "bool hasSelectedText"This property holds whether there is any text selected..PPhasSelectedText() returns TRUE if some or all of the text has been selected by the user (e.g. by clicking and dragging); otherwise returns FALSE..PPSee also selectedText..PPGet this property's value with hasSelectedText()..SH "QString markedText"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis property holds the text selected by the user (e.g. by clicking and dragging), or QString::null if no text is selected..PPGet this property's value with markedText()..PPSee also hasSelectedText..SH "int maxLength"This property holds the maximum permitted length of the text in the editor..PPIf the text is too long, it is truncated at the limit..PPIf truncation occurs any selected text will be unselected, the cursor position is set to 0 and the first part of the string is shown..PPSet this property's value with setMaxLength() and get this property's value with maxLength()..SH "bool readOnly"This property holds whether the line edit is read only..PPIn read-only mode, the user can still copy the text to the clipboard or drag-and-drop the text, but cannot edit it..PPQLineEdit does not show a cursor in read-only mode..PPSee also enabled..PPSet this property's value with setReadOnly() and get this property's value with isReadOnly()..SH "bool redoAvailable"This property holds whether redo is available..PPGet this property's value with isRedoAvailable()..SH "QString selectedText"This property holds any text selected by the user or QString::null..PPGet this property's value with selectedText()..PPSee also hasSelectedText..SH "QString text"This property holds the text in the line..PPSetting this property clears the selection and moves the cursor to the end of the line..PPThe text is truncated to maxLength() length..PPSet this property's value with setText() and get this property's value with text()..SH "bool undoAvailable"This property holds whether undo is available..PPGet this property's value with isUndoAvailable()..SH "SEE ALSO".BR http://doc.trolltech.com/qlineedit.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qlineedit.3qt) and the Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -