<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/widgets/qlineedit.cpp:220 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QLineEdit Class</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QLineEdit Class Reference</h1> <p>The QLineEdit widget is a one-line text editor. <a href="#details">More...</a> <p><tt>#include <<a href="qlineedit-h.html">qlineedit.h</a>></tt> <p>Inherits <a href="qframe.html">QFrame</a>. <p><a href="qlineedit-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li><div class=fn><a href="#QLineEdit"><b>QLineEdit</b></a> ( QWidget * parent, const char * name = 0 )</div></li> <li><div class=fn><a href="#QLineEdit-2"><b>QLineEdit</b></a> ( const QString & contents, QWidget * parent, const char * name = 0 )</div></li> <li><div class=fn><a href="#~QLineEdit"><b>~QLineEdit</b></a> ()</div></li> <li><div class=fn>QString <a href="#text"><b>text</b></a> () const</div></li> <li><div class=fn>QString <a href="#displayText"><b>displayText</b></a> () const</div></li> <li><div class=fn>int <a href="#maxLength"><b>maxLength</b></a> () const</div></li> <li><div class=fn>bool <a href="#frame"><b>frame</b></a> () const</div></li> <li><div class=fn>enum <a href="#EchoMode-enum"><b>EchoMode</b></a> { Normal, NoEcho, Password }</div></li> <li><div class=fn>EchoMode <a href="#echoMode"><b>echoMode</b></a> () const</div></li> <li><div class=fn>bool <a href="#isReadOnly"><b>isReadOnly</b></a> () const</div></li> <li><div class=fn>const QValidator * <a href="#validator"><b>validator</b></a> () const</div></li> <li><div class=fn>virtual QSize <a href="#sizeHint"><b>sizeHint</b></a> () const</div></li> <li><div class=fn>virtual QSize <a href="#minimumSizeHint"><b>minimumSizeHint</b></a> () const</div></li> <li><div class=fn>int <a href="#cursorPosition"><b>cursorPosition</b></a> () const</div></li> <li><div class=fn>bool <a href="#validateAndSet"><b>validateAndSet</b></a> ( const QString & newText, int newPos, int newMarkAnchor, int newMarkDrag )</div></li> <li><div class=fn>int <a href="#alignment"><b>alignment</b></a> () const</div></li> <li><div class=fn>void cursorLeft ( bool mark, int steps = 1 ) <em>(obsolete)</em></div></li> <li><div class=fn>void cursorRight ( bool mark, int steps = 1 ) <em>(obsolete)</em></div></li> <li><div class=fn>void <a href="#cursorForward"><b>cursorForward</b></a> ( bool mark, int steps = 1 )</div></li> <li><div class=fn>void <a href="#cursorBackward"><b>cursorBackward</b></a> ( bool mark, int steps = 1 )</div></li> <li><div class=fn>void <a href="#cursorWordForward"><b>cursorWordForward</b></a> ( bool mark )</div></li> <li><div class=fn>void <a href="#cursorWordBackward"><b>cursorWordBackward</b></a> ( bool mark )</div></li> <li><div class=fn>void <a href="#backspace"><b>backspace</b></a> ()</div></li> <li><div class=fn>void <a href="#del"><b>del</b></a> ()</div></li> <li><div class=fn>void <a href="#home"><b>home</b></a> ( bool mark )</div></li> <li><div class=fn>void <a href="#end"><b>end</b></a> ( bool mark )</div></li> <li><div class=fn>void <a href="#setEdited"><b>setEdited</b></a> ( bool )</div></li> <li><div class=fn>bool <a href="#edited"><b>edited</b></a> () const</div></li> <li><div class=fn>bool <a href="#hasSelectedText"><b>hasSelectedText</b></a> () const</div></li> <li><div class=fn>QString <a href="#selectedText"><b>selectedText</b></a> () const</div></li> <li><div class=fn>bool <a href="#getSelection"><b>getSelection</b></a> ( int * start, int * end )</div></li> <li><div class=fn>bool <a href="#isUndoAvailable"><b>isUndoAvailable</b></a> () const</div></li> <li><div class=fn>bool <a href="#isRedoAvailable"><b>isRedoAvailable</b></a> () const</div></li> <li><div class=fn>bool hasMarkedText () const <em>(obsolete)</em></div></li> <li><div class=fn>QString markedText () const <em>(obsolete)</em></div></li> <li><div class=fn>void <b>setPasswordChar</b> ( QChar c )</div></li> <li><div class=fn>QChar <b>passwordChar</b> () const</div></li> <li><div class=fn>bool <a href="#dragEnabled"><b>dragEnabled</b></a> () const</div></li> <li><div class=fn>int <a href="#characterAt"><b>characterAt</b></a> ( int xpos, QChar * chr ) const</div></li> </ul> <h2>Public Slots</h2> <ul> <li><div class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString & )</div></li> <li><div class=fn>virtual void <a href="#selectAll"><b>selectAll</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#deselect"><b>deselect</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#clearValidator"><b>clearValidator</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#insert"><b>insert</b></a> ( const QString & newText )</div></li> <li><div class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#undo"><b>undo</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#redo"><b>redo</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#setMaxLength"><b>setMaxLength</b></a> ( int )</div></li> <li><div class=fn>virtual void <a href="#setFrame"><b>setFrame</b></a> ( bool )</div></li> <li><div class=fn>virtual void <a href="#setEchoMode"><b>setEchoMode</b></a> ( EchoMode )</div></li> <li><div class=fn>virtual void <a href="#setReadOnly"><b>setReadOnly</b></a> ( bool )</div></li> <li><div class=fn>virtual void <a href="#setValidator"><b>setValidator</b></a> ( const QValidator * v )</div></li> <li><div class=fn>virtual void <a href="#setSelection"><b>setSelection</b></a> ( int start, int length )</div></li> <li><div class=fn>virtual void <a href="#setCursorPosition"><b>setCursorPosition</b></a> ( int )</div></li> <li><div class=fn>virtual void <a href="#setAlignment"><b>setAlignment</b></a> ( int flag )</div></li> <li><div class=fn>virtual void <a href="#cut"><b>cut</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#copy"><b>copy</b></a> () const</div></li> <li><div class=fn>virtual void <a href="#paste"><b>paste</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#setDragEnabled"><b>setDragEnabled</b></a> ( bool b )</div></li> </ul> <h2>Signals</h2> <ul> <li><div class=fn>void <a href="#textChanged"><b>textChanged</b></a> ( const QString & )</div></li> <li><div class=fn>void <a href="#returnPressed"><b>returnPressed</b></a> ()</div></li> <li><div class=fn>void <a href="#selectionChanged"><b>selectionChanged</b></a> ()</div></li> </ul> <h2>Properties</h2> <ul> <li><div class=fn>Alignment <a href="#alignment-prop"><b>alignment</b></a> - the alignment of the line edit</div></li> <li><div class=fn>int <a href="#cursorPosition-prop"><b>cursorPosition</b></a> - the current cursor position for this line edit</div></li> <li><div class=fn>QString <a href="#displayText-prop"><b>displayText</b></a> - the text that is displayed <em>(read only)</em></div></li> <li><div class=fn>bool <a href="#dragEnabled-prop"><b>dragEnabled</b></a> - whether the lineedit starts a drag if the user presses and moves the mouse on some selected text</div></li> <li><div class=fn>EchoMode <a href="#echoMode-prop"><b>echoMode</b></a> - the echo mode of the line edit</div></li> <li><div class=fn>bool <a href="#edited-prop"><b>edited</b></a> - the edited flag of the line edit</div></li> <li><div class=fn>bool <a href="#frame-prop"><b>frame</b></a> - whether the line edit draws itself with a frame</div></li> <li><div class=fn>bool hasMarkedText - whether part of the text has been selected by the user (e.g. by clicking and dragging) <em>(read only)</em> <em>(obsolete)</em></div></li> <li><div class=fn>bool <a href="#hasSelectedText-prop"><b>hasSelectedText</b></a> - whether there is any text selected <em>(read only)</em></div></li> <li><div class=fn>QString markedText - the text selected by the user (e.g. by clicking and dragging), or QString::null if no text is selected <em>(read only)</em> <em>(obsolete)</em></div></li> <li><div class=fn>int <a href="#maxLength-prop"><b>maxLength</b></a> - the maximum permitted length of the text in the editor</div></li> <li><div class=fn>bool <a href="#readOnly-prop"><b>readOnly</b></a> - whether the line edit is read only</div></li> <li><div class=fn>bool <a href="#redoAvailable-prop"><b>redoAvailable</b></a> - whether redo is available <em>(read only)</em></div></li> <li><div class=fn>QString <a href="#selectedText-prop"><b>selectedText</b></a> - any text selected by the user or QString::null <em>(read only)</em></div></li> <li><div class=fn>QString <a href="#text-prop"><b>text</b></a> - the text in the line</div></li> <li><div class=fn>bool <a href="#undoAvailable-prop"><b>undoAvailable</b></a> - whether undo is available <em>(read only)</em></div></li> </ul> <h2>Protected Members</h2> <ul> <li><div class=fn>virtual void <a href="#keyPressEvent"><b>keyPressEvent</b></a> ( QKeyEvent * e )</div></li> <li><div class=fn>void repaintArea ( int from, int to ) <em>(obsolete)</em></div></li> <li><div class=fn>virtual QPopupMenu * <a href="#createPopupMenu"><b>createPopupMenu</b></a> ()</div></li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> <p> The QLineEdit widget is a one-line text editor. <p> <p> A 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. <p> By changing the <a href="#echoMode">echoMode</a>() of a line edit, it can also be used as a "write-only" field, for inputs such as passwords. <p> The length of the field can be constrained to <a href="#maxLength">maxLength</a>(), or the value can be arbitrarily constrained by setting a <a href="#validator">validator</a>(). <p> A closely related class is <a href="qtextedit.html">QTextEdit</a> which allows multi-line, rich-text editing. <p> You can change the text with <a href="#setText">setText</a>() or <a href="#insert">insert</a>(). The text is retrieved with <a href="#text">text</a>(); the displayed text (which may be different, see <a href="#EchoMode-enum">EchoMode</a>) is retrieved with <a href="#displayText">displayText</a>(). Text can be selected with <a href="#setSelection">setSelection</a>() or <a href="#selectAll">selectAll</a>(), and the selection can be <a href="#cut">cut</a>(), <a href="#copy">copy</a>()ied and <a href="#paste">paste</a>()d. The text can be aligned with <a href="#setAlignment">setAlignment</a>(). <p> When the text changes the <a href="#textChanged">textChanged</a>() signal is emitted; when the Return or Enter key is pressed the <a href="#returnPressed">returnPressed</a>() signal is emitted. <p> By default, QLineEdits have a frame as specified by the Windows and Motif style guides; you can turn it off by calling <a href="#setFrame">setFrame</a>(FALSE). <p> The default key bindings are described below. A right mouse button menu presents some of the editing commands to the user. <a name="desc"></a> <ul> <li> <em>Left</em> Arrow - moves the cursor one character to the left. <li> <em>Right</em> Arrow - moves the cursor one character to the right. <li> <em>Backspace</em> - deletes the character to the left of the cursor. <li> <em>Home</em> - moves the cursor to the beginning of the line. <li> <em>End</em> - moves the cursor to the end of the line. <li> <em>Delete</em> - deletes the character to the right of the cursor. <li> <em>Shift+Left</em> Arrow - moves and selects text one character to the left. <li> <em>Shift+Right</em> Arrow - moves and selects text one character to the right. <li> <em>Ctrl+A</em> - moves the cursor to the beginning of the line. <li> <em>Ctrl+B</em> - moves the cursor one character to the left. <li> <em>Ctrl+C</em> - copies the selected text to the clipboard. (Windows also supports Ctrl+Insert for this operation.) <li> <em>Ctrl+D</em> - deletes the character to the right of the cursor. <li> <em>Ctrl+E</em> - moves the cursor to the end of the line. <li> <em>Ctrl+F</em> - moves the cursor one character to the right. <li> <em>Ctrl+H</em> - deletes the character to the left of the cursor. <li> <em>Ctrl+K</em> - deletes to the end of the line. <li> <em>Ctrl+V</em> - pastes the clipboard text into line edit. (Windows also supports Shift+Insert for this operation.) <li> <em>Ctrl+X</em> - deletes the selected text and copies it to the clipboard. (Windows also supports Shift+Delete for this operation.) <li> <em>Ctrl+Z</em> - undoes the last operation. <li> <em>Ctrl+Y</em> - redoes the last undone operation. </ul> <p> Any other key sequence, that represents a valid character, will cause the character to be inserted into the line. <p> <img src=qlined-m.png> <img src=qlined-w.png> <p> <p>See also <a href="qtextedit.html">QTextEdit</a>, <a href="qlabel.html">QLabel</a>, <a href="qcombobox.html">QComboBox</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Field, Entry</a> and <a href="basic.html">Basic Widgets</a>. <hr><h2>Member Type Documentation</h2> <h3 class=fn><a name="EchoMode-enum"></a>QLineEdit::EchoMode</h3> <p> This enum type describes how a line edit should display its contents. The defined values are: <ul> <li><tt>QLineEdit::Normal</tt> - display characters as they are entered. This is the default. <li><tt>QLineEdit::NoEcho</tt> - do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret. <li><tt>QLineEdit::Password</tt> - display asterisks instead of the characters actually entered. </ul><p> <p>See also <a href="#echoMode-prop">echoMode</a> and <a href="#echoMode-prop">echoMode</a>. <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QLineEdit"></a>QLineEdit::QLineEdit ( <a href="qwidget.html">QWidget</a> * parent, const char * name = 0 ) </h3> Constructs a line edit with no text. <p> The maximum text length is set to 32767 characters. <p> The <em>parent</em> and <em>name</em> arguments are sent to the <a href="qwidget.html">QWidget</a> constructor. <p> <p>See also <a href="#text-prop">text</a> and <a href="#maxLength-prop">maxLength</a>. <h3 class=fn><a name="QLineEdit-2"></a>QLineEdit::QLineEdit ( const <a href="qstring.html">QString</a> & contents, <a href="qwidget.html">QWidget</a> * parent, const char * name = 0 ) </h3> Constructs a line edit containing the text <em>contents</em>. <p> The cursor position is set to the end of the line and the maximum text length to 32767 characters. <p> The <em>parent</em> and <em>name</em> arguments are sent to the <a href="qwidget.html">QWidget</a> constructor. <p> <p>See also <a href="#text-prop">text</a> and <a href="#maxLength-prop">maxLength</a>. <h3 class=fn><a name="~QLineEdit"></a>QLineEdit::~QLineEdit () </h3> Destroys the line edit. <h3 class=fn>int <a name="alignment"></a>QLineEdit::alignment () const </h3><p>Returns the alignment of the line edit. See the <a href="qlineedit.html#alignment-prop">"alignment"</a> property for details. <h3 class=fn>void <a name="backspace"></a>QLineEdit::backspace () </h3> 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. <p> <p>See also <a href="#del">del</a>(). <h3 class=fn>int <a name="characterAt"></a>QLineEdit::characterAt ( int xpos, <a href="qchar.html">QChar</a> * chr ) const </h3> Returns the index position of the character which is at <em>xpos</em> (in logical coordinates from the left). If <em>chr</em> is not 0, <tt>*<em>chr</em></tt> is populated with the character at this position. <h3 class=fn>void <a name="clear"></a>QLineEdit::clear ()<tt> [virtual slot]</tt> </h3> Clears the contents of the editor. This is equivalent to <a href="#setText">setText</a>(""). <h3 class=fn>void <a name="clearValidator"></a>QLineEdit::clearValidator ()<tt> [virtual slot]</tt> </h3> This slot is equivalent to <a href="#setValidator">setValidator</a>( 0 ). <h3 class=fn>void <a name="copy"></a>QLineEdit::copy () const<tt> [virtual slot]</tt> </h3> Copies the selected text to the clipboard, if there is any, and if <a href="#echoMode">echoMode</a>() is Normal. <p> <p>See also <a href="#cut">cut</a>() and <a href="#paste">paste</a>(). <h3 class=fn><a href="qpopupmenu.html">QPopupMenu</a> * <a name="createPopupMenu"></a>QLineEdit::createPopupMenu ()<tt> [virtual protected]</tt> </h3> 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. <h3 class=fn>void <a name="cursorBackward"></a>QLineEdit::cursorBackward ( bool mark, int steps = 1 ) </h3> Moves the cursor back <em>steps</em> characters. If <em>mark</em> is TRUE each character moved over is added to the selection; if <em>mark</em> is FALSE the selection is cleared. <p> <p>See also <a href="#cursorForward">cursorForward</a>(). <h3 class=fn>void <a name="cursorForward"></a>QLineEdit::cursorForward ( bool mark, int steps = 1 ) </h3> Moves the cursor forward <em>steps</em> characters. If <em>mark</em> is TRUE each character moved over is added to the selection; if <em>mark</em> is FALSE the selection is cleared. <p> <p>See also <a href="#cursorBackward">cursorBackward</a>(). <h3 class=fn>void <a name="cursorLeft"></a>QLineEdit::cursorLeft ( bool mark, int steps = 1 ) </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> For compatibilty with older applications only. Use <a href="#cursorBackward">cursorBackward</a>() instead. <p>See also <a href="#cursorBackward">cursorBackward</a>(). <h3 class=fn>int <a name="cursorPosition"></a>QLineEdit::cursorPosition () const </h3><p>Returns the current cursor position for this line edit. See the <a href="qlineedit.html#cursorPosition-prop">"cursorPosition"</a> property for details. <h3 class=fn>void <a name="cursorRight"></a>QLineEdit::cursorRight ( bool mark, int steps = 1 ) </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> <p> Use <a href="#cursorForward">cursorForward</a>() instead. <p> <p>See also <a href="#cursorForward">cursorForward</a>(). <h3 class=fn>void <a name="cursorWordBackward"></a>QLineEdit::cursorWordBackward ( bool mark ) </h3> Moves the cursor one word backward. If <em>mark</em> is TRUE, the word is also selected. <p>See also <a href="#cursorWordForward">cursorWordForward</a>(). <h3 class=fn>void <a name="cursorWordForward"></a>QLineEdit::cursorWordForward ( bool mark ) </h3> Moves the cursor one word forward. If <em>mark</em> is TRUE, the word is also selected. <p>See also <a href="#cursorWordBackward">cursorWordBackward</a>(). <h3 class=fn>void <a name="cut"></a>QLineEdit::cut ()<tt> [virtual slot]</tt> </h3> Copies the selected text to the clipboard and deletes it, if there is any, and if <a href="#echoMode">echoMode</a>() is Normal. <p> If the current validator disallows deleting the selected text, <a href="#cut">cut</a>() will copy it but not delete it. <p> <p>See also <a href="#copy">copy</a>() and <a href="#paste">paste</a>(). <h3 class=fn>void <a name="del"></a>QLineEdit::del () </h3> 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. <p> <p>See also <a href="#backspace">backspace</a>(). <h3 class=fn>void <a name="deselect"></a>QLineEdit::deselect ()<tt> [virtual slot]</tt> </h3> De-selects all text (i.e. removes highlighting) and leaves the cursor at the current position. <p> <p>See also <a href="#setSelection">setSelection</a>() and <a href="#selectAll">selectAll</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="displayText"></a>QLineEdit::displayText () const </h3><p>Returns the text that is displayed. See the <a href="qlineedit.html#displayText-prop">"displayText"</a> property for details. <h3 class=fn>bool <a name="dragEnabled"></a>QLineEdit::dragEnabled () const </h3><p>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 <a href="qlineedit.html#dragEnabled-prop">"dragEnabled"</a> property for details. <h3 class=fn><a href="qlineedit.html#EchoMode-enum">EchoMode</a> <a name="echoMode"></a>QLineEdit::echoMode () const </h3><p>Returns the echo mode of the line edit. See the <a href="qlineedit.html#echoMode-prop">"echoMode"</a> property for details. <h3 class=fn>bool <a name="edited"></a>QLineEdit::edited () const </h3><p>Returns the edited flag of the line edit. See the <a href="qlineedit.html#edited-prop">"edited"</a> property for details. <h3 class=fn>void <a name="end"></a>QLineEdit::end ( bool mark ) </h3> Moves the text cursor to the end of the line. If <em>mark</em> is TRUE, text is selected towards the last position; otherwise, any selected text is unselected if the cursor is moved. <p> <p>See also <a href="#home">home</a>(). <h3 class=fn>bool <a name="frame"></a>QLineEdit::frame () const </h3><p>Returns TRUE if the line edit draws itself with a frame; otherwise returns FALSE. See the <a href="qlineedit.html#frame-prop">"frame"</a> property for details. <h3 class=fn>bool <a name="getSelection"></a>QLineEdit::getSelection ( int * start, int * end ) </h3> This function sets <tt>*<em>start</em></tt> to the position in the text where the selection starts and <tt>*<em>end</em></tt> to the position where the selection ends. Returns TRUE if <em>start</em> and <em>end</em> are not null and if there is some selected text; otherwise returns FALSE. <p> <p>See also <a href="#setSelection">setSelection</a>(). <h3 class=fn>bool <a name="hasMarkedText"></a>QLineEdit::hasMarkedText () const </h3><p>Returns TRUE if part of the text has been selected by the user (e.g. by clicking and dragging); otherwise returns FALSE. See the <a href="qlineedit.html#hasMarkedText-prop">"hasMarkedText"</a> property for details. <h3 class=fn>bool <a name="hasSelectedText"></a>QLineEdit::hasSelectedText () const </h3><p>Returns TRUE if there is any text selected; otherwise returns FALSE. See the <a href="qlineedit.html#hasSelectedText-prop">"hasSelectedText"</a> property for details. <h3 class=fn>void <a name="home"></a>QLineEdit::home ( bool mark ) </h3> Moves the text cursor to the beginning of the line. If <em>mark</em> is TRUE, text is selected towards the first position; otherwise, any selected text is unselected if the cursor is moved. <p> <p>See also <a href="#end">end</a>(). <h3 class=fn>void <a name="insert"></a>QLineEdit::insert ( const <a href="qstring.html">QString</a> & newText )<tt> [virtual slot]</tt> </h3> Removes any selected text, inserts <em>newText</em>, and validates the result. If it is valid, it sets it as the new contents of the line edit. <h3 class=fn>bool <a name="isReadOnly"></a>QLineEdit::isReadOnly () const </h3><p>Returns TRUE if the line edit is read only; otherwise returns FALSE. See the <a href="qlineedit.html#readOnly-prop">"readOnly"</a> property for details. <h3 class=fn>bool <a name="isRedoAvailable"></a>QLineEdit::isRedoAvailable () const </h3><p>Returns TRUE if redo is available; otherwise returns FALSE. See the <a href="qlineedit.html#redoAvailable-prop">"redoAvailable"</a> property for details. <h3 class=fn>bool <a name="isUndoAvailable"></a>QLineEdit::isUndoAvailable () const </h3><p>Returns TRUE if undo is available; otherwise returns FALSE. See the <a href="qlineedit.html#undoAvailable-prop">"undoAvailable"</a> property for details. <h3 class=fn>void <a name="keyPressEvent"></a>QLineEdit::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a> * e )<tt> [virtual protected]</tt> </h3> Converts key press event <em>e</em> into a line edit action. <p> If Return or Enter is pressed and the current text is valid (or can be <a href="qvalidator.html#fixup">made valid</a> by the validator), the signal returnPressed is emitted. <p> The default key bindings are listed in the <a href="#desc">detailed description.</a> <p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="markedText"></a>QLineEdit::markedText () const </h3><p>Returns the text selected by the user (e.g. by clicking and dragging), or QString::null if no text is selected. See the <a href="qlineedit.html#markedText-prop">"markedText"</a> property for details. <h3 class=fn>int <a name="maxLength"></a>QLineEdit::maxLength () const </h3><p>Returns the maximum permitted length of the text in the editor. See the <a href="qlineedit.html#maxLength-prop">"maxLength"</a> property for details. <h3 class=fn><a href="qsize.html">QSize</a> <a name="minimumSizeHint"></a>QLineEdit::minimumSizeHint () const<tt> [virtual]</tt> </h3> Returns a minimum size for the line edit. <p> The width returned is enough for at least one character. <p>Reimplemented from <a href="qwidget.html#minimumSizeHint">QWidget</a>. <h3 class=fn>void <a name="paste"></a>QLineEdit::paste ()<tt> [virtual slot]</tt> </h3> Inserts the clipboard's text at the cursor position, deleting any selected text. <p> If the end result is not acceptable for the current validator, nothing happens. <p> <p>See also <a href="#copy">copy</a>() and <a href="#cut">cut</a>(). <h3 class=fn>void <a name="redo"></a>QLineEdit::redo ()<tt> [virtual slot]</tt> </h3> Redoes the last operation <h3 class=fn>void <a name="repaintArea"></a>QLineEdit::repaintArea ( int from, int to )<tt> [protected]</tt> </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Repaints all characters from <em>from</em> to <em>to</em>. If cursorPos is between from and to, ensures that cursorPos is visible. <h3 class=fn>void <a name="returnPressed"></a>QLineEdit::returnPressed ()<tt> [signal]</tt> </h3> This signal is emitted when the Return or Enter key is pressed. <p>Example: <a href="popup-example.html#x884">popup/popup.cpp</a>. <h3 class=fn>void <a name="selectAll"></a>QLineEdit::selectAll ()<tt> [virtual slot]</tt> </h3> 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. <p> <p>See also <a href="#setSelection">setSelection</a>() and <a href="#deselect">deselect</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="selectedText"></a>QLineEdit::selectedText () const </h3><p>Returns any text selected by the user or QString::null. See the <a href="qlineedit.html#selectedText-prop">"selectedText"</a> property for details. <h3 class=fn>void <a name="selectionChanged"></a>QLineEdit::selectionChanged ()<tt> [signal]</tt> </h3> <p> This signal is emitted whenever the selection changes. <p> <p>See also <a href="#hasSelectedText-prop">hasSelectedText</a> and <a href="#selectedText-prop">selectedText</a>. <h3 class=fn>void <a name="setAlignment"></a>QLineEdit::setAlignment ( int flag )<tt> [virtual slot]</tt> </h3><p>Sets the alignment of the line edit to <em>flag</em>. See the <a href="qlineedit.html#alignment-prop">"alignment"</a> property for details. <h3 class=fn>void <a name="setCursorPosition"></a>QLineEdit::setCursorPosition ( int )<tt> [virtual slot]</tt> </h3><p>Sets the current cursor position for this line edit. See the <a href="qlineedit.html#cursorPosition-prop">"cursorPosition"</a> property for details. <h3 class=fn>void <a name="setDragEnabled"></a>QLineEdit::setDragEnabled ( bool b )<tt> [virtual slot]</tt> </h3><p>Sets whether the lineedit starts a drag if the user presses and moves the mouse on some selected text to <em>b</em>. See the <a href="qlineedit.html#dragEnabled-prop">"dragEnabled"</a> property for details. <h3 class=fn>void <a name="setEchoMode"></a>QLineEdit::setEchoMode ( <a href="qlineedit.html#EchoMode-enum">EchoMode</a> )<tt> [virtual slot]</tt> </h3><p>Sets the echo mode of the line edit. See the <a href="qlineedit.html#echoMode-prop">"echoMode"</a> property for details. <h3 class=fn>void <a name="setEdited"></a>QLineEdit::setEdited ( bool ) </h3><p>Sets the edited flag of the line edit. See the <a href="qlineedit.html#edited-prop">"edited"</a> property for details. <h3 class=fn>void <a name="setFrame"></a>QLineEdit::setFrame ( bool )<tt> [virtual slot]</tt> </h3><p>Sets whether the line edit draws itself with a frame. See the <a href="qlineedit.html#frame-prop">"frame"</a> property for details. <h3 class=fn>void <a name="setMaxLength"></a>QLineEdit::setMaxLength ( int )<tt> [virtual slot]</tt> </h3><p>Sets the maximum permitted length of the text in the editor. See the <a href="qlineedit.html#maxLength-prop">"maxLength"</a> property for details. <h3 class=fn>void <a name="setReadOnly"></a>QLineEdit::setReadOnly ( bool )<tt> [virtual slot]</tt> </h3><p>Sets whether the line edit is read only. See the <a href="qlineedit.html#readOnly-prop">"readOnly"</a> property for details. <h3 class=fn>void <a name="setSelection"></a>QLineEdit::setSelection ( int start, int length )<tt> [virtual slot]</tt> </h3> Sets the selected area of this line edit to start at position <em>start</em> and be <em>length</em> characters long. <p> <p>See also <a href="#deselect">deselect</a>(), <a href="#selectAll">selectAll</a>() and <a href="#getSelection">getSelection</a>(). <h3 class=fn>void <a name="setText"></a>QLineEdit::setText ( const <a href="qstring.html">QString</a> & )<tt> [virtual slot]</tt> </h3><p>Sets the text in the line. See the <a href="qlineedit.html#text-prop">"text"</a> property for details. <h3 class=fn>void <a name="setValidator"></a>QLineEdit::setValidator ( const <a href="qvalidator.html">QValidator</a> * v )<tt> [virtual slot]</tt> </h3> Sets this line edit to accept input only as accepted by the validator, <em>v</em>, allowing arbitrary constraints on the text which may be entered. <p> If <em>v</em> == 0, <a href="#setValidator">setValidator</a>() removes the current input validator. The initial setting is to have no input validator (i.e. any input is accepted up to <a href="#maxLength">maxLength</a>()). <p> <p>See also <a href="#validator">validator</a>() and <a href="qvalidator.html">QValidator</a>. <p>Examples: <a href="lineedits-example.html#x1302">lineedits/lineedits.cpp</a> and <a href="wizard-example.html#x144">wizard/wizard.cpp</a>. <h3 class=fn><a href="qsize.html">QSize</a> <a name="sizeHint"></a>QLineEdit::sizeHint () const<tt> [virtual]</tt> </h3> Returns a recommended size for the widget. <p> The width returned, in pixels, is usually enough for about 15 to 20 characters. <p>Example: <a href="addressbook-example.html#x1972">addressbook/centralwidget.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QLineEdit::text () const </h3><p>Returns the text in the line. See the <a href="qlineedit.html#text-prop">"text"</a> property for details. <h3 class=fn>void <a name="textChanged"></a>QLineEdit::textChanged ( const <a href="qstring.html">QString</a> & )<tt> [signal]</tt> </h3> This signal is emitted whenever the text changes. The argument is the new text. <p>Examples: <a href="wizard-example.html#x146">wizard/wizard.cpp</a> and <a href="xform-example.html#x85">xform/xform.cpp</a>. <h3 class=fn>void <a name="undo"></a>QLineEdit::undo ()<tt> [virtual slot]</tt> </h3> Undoes the last operation <h3 class=fn>bool <a name="validateAndSet"></a>QLineEdit::validateAndSet ( const <a href="qstring.html">QString</a> & newText, int newPos, int newMarkAnchor, int newMarkDrag ) </h3> Validates and perhaps sets this line edit to contain <em>newText</em> with the cursor at position <em>newPos</em>, with selected text from <em>newMarkAnchor</em> to <em>newMarkDrag</em>. Returns TRUE if it changes the line edit; otherwise returns FALSE. <p> Linebreaks in <em>newText</em> are converted to spaces, and the text is truncated to <a href="#maxLength">maxLength</a>() before its validity is tested. <p> Repaints and emits <a href="#textChanged">textChanged</a>() if appropriate. <h3 class=fn>const <a href="qvalidator.html">QValidator</a> * <a name="validator"></a>QLineEdit::validator () const </h3> Returns a pointer to the current input validator, or 0 if no validator has been set. <p> <p>See also <a href="#setValidator">setValidator</a>(). <p>Example: <a href="wizard-example.html#x147">wizard/wizard.cpp</a>. <hr><h2>Property Documentation</h2> <h3 class=fn>Alignment <a name="alignment-prop"></a>alignment</h3> <p>This property holds the alignment of the line edit. <p>Possible Values are Qt::AlignAuto, Qt::AlignLeft, Qt::AlignRight and Qt::AlignHCenter. <p> Attempting to set the alignment to an illegal flag combination does nothing. <p> <p>See also <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>. <p>Set this property's value with <a href="#setAlignment">setAlignment</a>() and get this property's value with <a href="#alignment">alignment</a>(). <h3 class=fn>int <a name="cursorPosition-prop"></a>cursorPosition</h3> <p>This property holds the current cursor position for this line edit. <p>Setting the cursor position causes a repaint when appropriate. <p>Set this property's value with <a href="#setCursorPosition">setCursorPosition</a>() and get this property's value with <a href="#cursorPosition">cursorPosition</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="displayText-prop"></a>displayText</h3> <p>This property holds the text that is displayed. <p>If EchoMode is Normal this returns the same as <a href="#text">text</a>(); 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, "". <p> <p>See also <a href="#echoMode-prop">echoMode</a>, <a href="#text-prop">text</a> and <a href="#EchoMode-enum">EchoMode</a>. <p>Get this property's value with <a href="#displayText">displayText</a>(). <h3 class=fn>bool <a name="dragEnabled-prop"></a>dragEnabled</h3> <p>This property holds whether the lineedit starts a drag if the user presses and moves the mouse on some selected text. <p> <p>Set this property's value with <a href="#setDragEnabled">setDragEnabled</a>() and get this property's value with <a href="#dragEnabled">dragEnabled</a>(). <h3 class=fn><a href="qlineedit.html#EchoMode-enum">EchoMode</a> <a name="echoMode-prop"></a>echoMode</h3> <p>This property holds the echo mode of the line edit. <p>The initial setting is Normal, but QLineEdit also supports NoEcho and Password modes. <p> The widget's display and the ability to copy or drag the text is affected by this setting. <p> <p>See also <a href="#EchoMode-enum">EchoMode</a> and <a href="#displayText-prop">displayText</a>. <p>Set this property's value with <a href="#setEchoMode">setEchoMode</a>() and get this property's value with <a href="#echoMode">echoMode</a>(). <h3 class=fn>bool <a name="edited-prop"></a>edited</h3> <p>This property holds the edited flag of the line edit. <p>The 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. <p> This 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 <a href="#edited">edited</a>() return value and set the line edit's contents if the user has not started editing the line edit. <p> Calling <a href="#setText">setText</a>() resets the edited flag to FALSE. <p>Set this property's value with <a href="#setEdited">setEdited</a>() and get this property's value with <a href="#edited">edited</a>(). <h3 class=fn>bool <a name="frame-prop"></a>frame</h3> <p>This property holds whether the line edit draws itself with a frame. <p>If enabled (the default) the line edit draws itself inside a two-pixel frame, otherwise the line edit draws itself without any frame. <p>Set this property's value with <a href="#setFrame">setFrame</a>() and get this property's value with <a href="#frame">frame</a>(). <h3 class=fn>bool <a name="hasMarkedText-prop"></a>hasMarkedText</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> <p>This property holds whether part of the text has been selected by the user (e.g. by clicking and dragging). <p>Get this property's value with <a href="#hasMarkedText">hasMarkedText</a>(). <p><p>See also <a href="#selectedText-prop">selectedText</a>. <h3 class=fn>bool <a name="hasSelectedText-prop"></a>hasSelectedText</h3> <p>This property holds whether there is any text selected. <p>hasSelectedText() returns TRUE if some or all of the text has been selected by the user (e.g. by clicking and dragging); otherwise returns FALSE. <p> <p>See also <a href="#selectedText-prop">selectedText</a>. <p>Get this property's value with <a href="#hasSelectedText">hasSelectedText</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="markedText-prop"></a>markedText</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> <p>This property holds the text selected by the user (e.g. by clicking and dragging), or QString::null if no text is selected. <p>Get this property's value with <a href="#markedText">markedText</a>(). <p><p>See also <a href="#hasSelectedText-prop">hasSelectedText</a>. <h3 class=fn>int <a name="maxLength-prop"></a>maxLength</h3> <p>This property holds the maximum permitted length of the text in the editor. <p>If the text is too long, it is truncated at the limit. <p> If truncation occurs any selected text will be unselected, the cursor position is set to 0 and the first part of the string is shown. <p>Set this property's value with <a href="#setMaxLength">setMaxLength</a>() and get this property's value with <a href="#maxLength">maxLength</a>(). <h3 class=fn>bool <a name="readOnly-prop"></a>readOnly</h3> <p>This property holds whether the line edit is read only. <p>In read-only mode, the user can still copy the text to the clipboard or drag-and-drop the text, but cannot edit it. <p> QLineEdit does not show a cursor in read-only mode. <p> <p>See also <a href="qwidget.html#enabled-prop">enabled</a>. <p>Set this property's value with <a href="#setReadOnly">setReadOnly</a>() and get this property's value with <a href="#isReadOnly">isReadOnly</a>(). <h3 class=fn>bool <a name="redoAvailable-prop"></a>redoAvailable</h3> <p>This property holds whether redo is available. <p> <p>Get this property's value with <a href="#isRedoAvailable">isRedoAvailable</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="selectedText-prop"></a>selectedText</h3> <p>This property holds any text selected by the user or QString::null. <p>Get this property's value with <a href="#selectedText">selectedText</a>(). <p><p>See also <a href="#hasSelectedText-prop">hasSelectedText</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3> <p>This property holds the text in the line. <p>Setting this property clears the selection, moves the cursor to the end of the line and resets the edited property to FALSE. <p> The text is truncated to <a href="#maxLength">maxLength</a>() length. <p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>(). <h3 class=fn>bool <a name="undoAvailable-prop"></a>undoAvailable</h3> <p>This property holds whether undo is available. <p> <p>Get this property's value with <a href="#isUndoAvailable">isUndoAvailable</a>(). <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2001 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2001 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>