QLineEdit(3qt)

NAME
QLineEdit - Simple line editor for inputting text

SYNOPSIS

#include <qlineedit.h>

Inherits QWidget.

  Public Members
QLineEdit ( QWidget * parent=0, const char * name=0 )
~QLineEdit ()
const char* text () const
int maxLength () const
void setMaxLength ( int )
void setFrame ( bool )
bool frame () const
enum EchoMode { Normal, NoEcho, Password }
void setEchoMode ( EchoMode )
EchoMode echoMode () const
void setValidator ( QValidator * )
QValidator* validator () const
virtual QSize sizeHint () const
virtual void setEnabled ( bool )
virtual void setFont ( const QFont & )
virtual void setPalette ( const QPalette & )
void setSelection ( int, int )
void setCursorPosition ( int )
int cursorPosition () const
bool validateAndSet ( const char *, int, int, int )
void cut ()
void copy () const
void paste ()

  Public Slots
void setText ( const char * )
void selectAll ()
void deselect ()
void clearValidator ()
void insert ( const char * )
void clear ()

  Signals
void textChanged ( const char * )
void returnPressed ()

  Protected Members
virtual void mousePressEvent ( QMouseEvent * )
virtual void mouseMoveEvent ( QMouseEvent * )
virtual void mouseReleaseEvent ( QMouseEvent * )
virtual void mouseDoubleClickEvent ( QMouseEvent * )
virtual void keyPressEvent ( QKeyEvent * )
virtual void focusInEvent ( QFocusEvent * )
virtual void focusOutEvent ( QFocusEvent * )
virtual void paintEvent ( QPaintEvent * )
virtual void timerEvent ( QTimerEvent * )
virtual void resizeEvent ( QResizeEvent * )
virtual void leaveEvent ( QEvent * )
virtual bool event ( QEvent * )
bool hasMarkedText () const
QString markedText () const
void repaintArea ( int, int )

DESCRIPTION
The QLineEdit widget is a simple line editor for inputting text.

The default QLineEdit object has its own frame as specified by the Windows/Motif style guides, you can turn off the frame by calling setFrame( FALSE ).

It draws the text using its own color group: colorGroup().text() on colorGroup().base(). The cursor and frame use other colors from same color group, of course.

QLineEdit can display the content of itself in three ways, depending on the current echo mode. The echo modes available are:

Normal - display characters as they are entered. This is the default.

NoEcho - do not display anything.

Password - display asterisks instead of the characters actually entered.

The default key bindings are described in keyPressEvent(); they cannot be customized except by inheriting the class.

[Image Omitted]

[Image Omitted]

See also: QMultiLineEdit, QLabel, QComboBox, GUI Design Handbook: Field, Entry, and GUI Design Handbook: Field, Required.

Examples: xform/xform.cpp layout/layout.cpp widgets/widgets.cpp

MEMBER FUNCTION DOCUMENTATION

QLineEdit::QLineEdit ( QWidget * parent=0, const char * name=0 )
Constructs a line editor with an empty edit buffer.

The cursor position is set to the start of the line, the maximum buffer size to 32767 characters, and the buffer contents to "".

The parent and name arguments are sent to the QWidget constructor.

QLineEdit::~QLineEdit ()
Destroys the line editor.

void QLineEdit::clear () [slot]
Syntax sugar for setText( "" ), provided to match no-argument signals.

void QLineEdit::clearValidator () [slot]
This slot is equivalent to setValidator( 0 ).

void QLineEdit::copy () const
Copies the marked text to the clipboard, if there is any.

See also: cut() and paste().

int QLineEdit::cursorPosition () const
Returns the current cursor position for this line edit.

See also: setCursorPosition().

void QLineEdit::cut ()
Copies the marked text to the clipboard and deletes it, if there is any.

If the current validator disallows deleting the marked text, cut() will copy it but not delete it.

See also: copy() and paste().

void QLineEdit::deselect () [slot]
Deselects all text (i.e. removes marking) and leaves the cursor at the current position.

QLineEdit::EchoMode QLineEdit::echoMode() const
Returns the current echo mode of the line edit.

See also: setEchoMode().

bool QLineEdit::event ( QEvent * e ) [virtual protected]
Don't use it if you don't mean it.

Reimplemented from QObject.

void QLineEdit::focusInEvent ( QFocusEvent * ) [virtual protected]
Handles the cursor blinking.

Reimplemented from QWidget.

void QLineEdit::focusOutEvent ( QFocusEvent * ) [virtual protected]
Handles the cursor blinking and selection copying.

Reimplemented from QWidget.

bool QLineEdit::frame () const
Returns TRUE if the line edit draws itself inside a frame, FALSE if it draws itself without any frame.

The default is to use a frame.

See also: setFrame().

bool QLineEdit::hasMarkedText () const [protected]
Returns TRUE if part of the text has been marked by the user (e.g. by clicking and dragging).

void QLineEdit::insert ( const char * newText ) [slot]
Removes any currently selected text, inserts newText, validates the result and if it is valid, sets it as the new contents of the line edit.

void QLineEdit::keyPressEvent ( QKeyEvent * e ) [virtual protected]
The key press event handler converts a key press to some line editor action.

If return or enter is pressed and the current text is valid (or if the validator can make the text valid), the signal returnPressed is emitted.

Here are the default key bindings:

Left Arrow  Move the cursor one character leftwards

Right Arrow  Move the cursor one character rightwards

Backspace  Delete the character to the left of the cursor

Home  Move the cursor to the beginning of the line

End  Move the cursor to the end of the line

Delete  Delete the character to the right of the cursor

Shift - Left Arrow  Mark text one character leftwards

Shift - Right Arrow  Mark text one character rightwards

Control-A  Move the cursor to the beginning of the line

Control-B  Move the cursor one character leftwards

Control-C  Copy the marked text to the clipboard.

Control-D  Delete the character to the right of the cursor

Control-E  Move the cursor to the end of the line

Control-F  Move the cursor one character rightwards

Control-H  Delete the character to the left of the cursor

Control-V  Paste the clipboard text into line edit.

Control-X  Cut the marked text, copy to clipboard.

All other keys with valid ASCII codes insert themselves into the line.

Reimplemented from QWidget.

void QLineEdit::leaveEvent ( QEvent * ) [virtual protected]
Handles selection copying.

Reimplemented from QWidget.

QString QLineEdit::markedText () const [protected]
Returns the text marked by the user (e.g. by clicking and dragging), or 0 if no text is marked.

See also: hasMarkedText().

int QLineEdit::maxLength () const
Returns the current maximum length of the text in the editor.

See also: setMaxLength().

void QLineEdit::mouseDoubleClickEvent ( QMouseEvent * ) [virtual protected]
Handles mouse double click events for this widget.

Reimplemented from QWidget.

void QLineEdit::mouseMoveEvent ( QMouseEvent * e ) [virtual protected]
Handles mouse move events for the line editor, primarily for marking text.

Reimplemented from QWidget.

void QLineEdit::mousePressEvent ( QMouseEvent * e ) [virtual protected]
Handles mouse press events for this widget.

Reimplemented from QWidget.

void QLineEdit::mouseReleaseEvent ( QMouseEvent * e ) [virtual protected]
Handles mouse release events for this widget.

Reimplemented from QWidget.

void QLineEdit::paintEvent ( QPaintEvent * e ) [virtual protected]
Handles paint events for the line editor.

Reimplemented from QWidget.

void QLineEdit::repaintArea ( int from, int to ) [protected]
Repaints all characters from from to to. If cursorPos is between from and to, ensures that cursorPos is visible.

void QLineEdit::resizeEvent ( QResizeEvent * ) [virtual protected]
Handles resize events for this widget.

Reimplemented from QWidget.

void QLineEdit::returnPressed () [signal]
This signal is emitted when the return or enter key is pressed.

void QLineEdit::selectAll () [slot]
Selects all text (i.e. marks it) and moves the cursor to the end. Useful when a default value has been inserted. If the user types before clicking on the widget the selected text will be erased.

void QLineEdit::setCursorPosition ( int newPos )
Set the cursor position for this line edit to newPos and repaint accordingly.

See also: cursorPosition().

void QLineEdit::setEchoMode ( EchoMode mode )
Sets the echo mode of the line edit widget.

The echo modes available are:

Normal - display characters as they are entered. This is the default.

NoEcho - do not display anything.

Password - display asterisks instead of the characters actually entered.

It is always possible to cut and paste any marked text; only the widget's own display is affected.

See also: echoMode().

void QLineEdit::setEnabled ( bool e ) [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QLineEdit::setFont ( const QFont & f ) [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QLineEdit::setFrame ( bool enable )
Sets the line edit to draw itself inside a two-pixel frame if enable is TRUE, and to draw itself without any frame if enable is FALSE.

The default is TRUE.

See also: frame() and QComboBox.

void QLineEdit::setMaxLength ( int m )
Set the maximum length of the text in the editor. If the text is currently too long, it is chopped off at the limit. Any marked text will be unmarked. The cursor position is set to 0 and the first part of the string is shown.

See also: maxLength().

void QLineEdit::setPalette ( const QPalette & p ) [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QLineEdit::setSelection ( int start, int length )
Sets the marked area of this line edit to start at start and be length characters long.

void QLineEdit::setText ( const char * text ) [slot]
Sets the line editor text to text, clears the selection and moves the cursor to the end of the line.

If necessary the text is truncated to fit maxLength().

See also: text().

Examples: xform/xform.cpp

void QLineEdit::setValidator ( QValidator * v )
Sets this line edit to accept input only as accepted by v.

If v == 0, remove the currently set input validator. The default is no input validator (ie. any input is accepted up to maxLength()).

See also: validator() and QValidator.

QSize QLineEdit::sizeHint () const [virtual]
Returns a size which fits the contents of the line edit.

The width returned tends to be enough for about 15-20 characters.

Examples: layout/layout.cpp widgets/widgets.cpp

Reimplemented from QWidget.

const char * QLineEdit::text () const
Returns a pointer to the text currently in the line.

If you need to store the text, you should make a copy of it. This can conveniently be done with a QString object:

    QString s = lineEd->text();  // makes a copy and stores it in s

See also: setText().

Examples: xform/xform.cpp

void QLineEdit::textChanged ( const char * ) [signal]
This signal is emitted every time the text has changed. The argument is the new text.

void QLineEdit::timerEvent ( QTimerEvent * e ) [virtual protected]
Not used.

Reimplemented from QObject.

bool QLineEdit::validateAndSet ( const char * newText, int newPos, int newMarkAnchor, int newMarkDrag )
Validates and perhaps sets this line edit to contain newText with the cursor at position newPos, with marked text from newMarkAnchor to newMarkDrag. Returns TRUE if it changes the line edit and FALSE if it doesn't.

If newText contains more than one line is longer than maxLength(), validateAndSet() truncates it before testing its validity.

Repaints and emits textChanged() if appropriate.

QValidator * QLineEdit::validator () const
Returns a pointer to the current input validator, or 0 if no validator has been set.

SEE ALSO
http://www.troll.no/qt/qlineedit.html

COPYRIGHT
Copyright 1992-1997 Troll Tech AS. See the LICENSE file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.