QLineEdit Class Reference


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

#include <qlined.h>

Inherits QWidget.

List of all member functions.

Public Members

Public Slots

Signals

Protected Members


Detailed Description

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

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

Examples: 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::focusInEvent ( QFocusEvent *) [virtual protected]

For internal use only.

Reimplemented from QWidget.

void QLineEdit::focusOutEvent ( QFocusEvent *) [virtual protected]

For internal use only.

Reimplemented from QWidget.

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::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, the signal returnPressed will be 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.

Comments solicited

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

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::mousePressEvent ( QMouseEvent *e) [virtual protected]

Handles mouse press events for this widget.

Reimplemented from QWidget.

void QLineEdit::mouseReleaseEvent ( QMouseEvent *) [virtual protected]

Handles mouse release events for this widget.

Reimplemented from QWidget.

void QLineEdit::resizeEvent ( QResizeEvent *e) [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 does an "end" operation. 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::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::setText ( const char *text) [slot]

Sets the line editor text to text.

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

See also: text().

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().

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 *) [virtual protected]

For internal use only.

Reimplemented from QObject.

void QWidget::mouseMoveEvent ( QMouseEvent *) [virtual protected]

This event handler can be reimplemented in a subclass to receive mouse move events for the widget.

If mouse tracking is switched off, mouse move events only occur if a mouse button is down while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is down.

The default implementation does nothing.

See also: setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event() and QMouseEvent.

Reimplemented in QMenuBar, QScrollBar, QComboBox, QListBox, QPopupMenu and QButton.

void QWidget::paintEvent ( QPaintEvent *) [virtual protected]

This event handler can be reimplemented in a subclass to receive widget paint events. Actually, it more or less must be reimplemented.

The default implementation does nothing.

When the paint event occurs, the update rectangle QPaintEvent::rect() normally has been cleared to the background color or pixmap. An exception is repaint() with erase=FALSE.

For many widgets it is sufficient to redraw the entire widget each time, but some need to consider the update rectangle to avoid flicker or slow update.

Pixmaps can also be used to implement flicker-free update.

update() and repaint() can be used to force a paint event.

See also: event(), repaint(), update(), QPainter, QPixmap and QPaintEvent.

Reimplemented in QFrame, QComboBox, QScrollBar, QTableView, QPopupMenu, QGroupBox and QButton.


This file is part of the Qt toolkit, copyright © 1995-96 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:51, 1996/09/24 for Qt version 1.0 by the webmaster at Troll Tech