TQLineEdit(3qt)

NAME
TQLineEdit - One-line text editor

SYNOPSIS
#include <tqlineedit.h>

Inherits TQFrame.

  Public Members
TQLineEdit ( TQWidget * parent, const char * name = 0 )
TQLineEdit ( const TQString & contents, TQWidget * parent, const char * name = 0 )
TQLineEdit ( const TQString & contents, const TQString & inputMask, TQWidget * parent, const char * name = 0 )
~TQLineEdit ()
TQString text () const
TQString displayText () const
int maxLength () const
bool frame () const
enum EchoMode { Normal, NoEcho, Password }
EchoMode echoMode () const
bool isReadOnly () const
const TQValidator * validator () const
virtual TQSize sizeHint () const
virtual TQSize minimumSizeHint () const
int cursorPosition () const
bool validateAndSet ( const TQString & newText, int newPos, int newMarkAnchor, int newMarkDrag ) (obsolete)
int alignment () const
void cursorForward ( bool mark, int steps = 1 )
void cursorBackward ( bool mark, int steps = 1 )
void cursorWordForward ( bool mark )
void cursorWordBackward ( bool mark )
void backspace ()
void del ()
void home ( bool mark )
void end ( bool mark )
bool isModified () const
void clearModified ()
bool edited () const (obsolete)
void setEdited ( bool ) (obsolete)
bool hasSelectedText () const
TQString selectedText () const
int selectionStart () const
bool isUndoAvailable () const
bool isRedoAvailable () const
bool dragEnabled () const
TQString inputMask () const
void setInputMask ( const TQString & inputMask )
bool hasAcceptableInput () const
int characterAt ( int xpos, TQChar * chr ) const (obsolete)
bool getSelection ( int * start, int * end ) (obsolete)

  Public Slots
virtual void setText ( const TQString & )
virtual void selectAll ()
virtual void deselect ()
virtual void clearValidator ()
virtual void insert ( const TQString & newText )
virtual void clear ()
virtual void undo ()
virtual void redo ()
virtual void setMaxLength ( int )
virtual void setFrame ( bool )
virtual void setEchoMode ( EchoMode )
virtual void setReadOnly ( bool )
virtual void setValidator ( const TQValidator * v )
virtual void setSelection ( int start, int length )
virtual void setCursorPosition ( int )
virtual void setAlignment ( int flag )
virtual void cut ()
virtual void copy () const
virtual void paste ()
virtual void setDragEnabled ( bool b )

  Signals
void textChanged ( const TQString & )
void returnPressed ()
void lostFocus ()
void selectionChanged ()

  Properties
bool acceptableInput - whether the input satisfies the inputMask and the validator (read only)
Alignment alignment - the alignment of the line edit
int cursorPosition - the current cursor position for this line edit
TQString displayText - the displayed text (read only)
bool dragEnabled - whether the lineedit starts a drag if the user presses and moves the mouse on some selected text
EchoMode echoMode - the line edit's echo mode
bool edited - whether the line edit has been edited. Use modified instead (obsolete)
bool frame - whether the line edit draws itself with a frame
bool hasSelectedText - whether there is any text selected (read only)
TQString inputMask - the validation input mask
int maxLength - the maximum permitted length of the text
bool modified - whether the line edit's contents has been modified by the user (read only)
bool readOnly - whether the line edit is read only
bool redoAvailable - whether redo is available (read only)
TQString selectedText - the selected text (read only)
TQString text - the line edit's text
bool undoAvailable - whether undo is available (read only)

  Protected Members
virtual void keyPressEvent ( TQKeyEvent * e )
virtual TQPopupMenu * createPopupMenu ()

DESCRIPTION
The TQLineEdit widget is a one-line text editor.

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.

By changing the echoMode() of a line edit, it can also be used as a "write-only" field, for inputs such as passwords.

The length of the text can be constrained to maxLength(). The text can be arbitrarily constrained using a validator() or an inputMask(), or both.

A related class is TQTextEdit which allows multi-line, rich-text editing.

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

When 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 Acceptable.

By default, TQLineEdits have a frame as specified by the Windows and Motif style guides; you can turn it off by calling setFrame(false).

The 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
</center>

Any other key sequence that represents a valid character, will cause the character to be inserted into the line edit.

[Image Omitted]

[Image Omitted]

See also TQTextEdit, TQLabel, TQComboBox, GUI Design Handbook: Field, Entry, and Basic Widgets.

  Member Type Documentation

TQLineEdit::EchoMode
This enum type describes how a line edit should display its contents.

TQLineEdit::Normal - Display characters as they are entered. This is the default.

TQLineEdit::NoEcho - Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret.

TQLineEdit::Password - Display asterisks instead of the characters actually entered.

See also echoMode and echoMode.

MEMBER FUNCTION DOCUMENTATION

TQLineEdit::TQLineEdit ( TQWidget * parent, const char * name = 0 )
Constructs a line edit with no text.

The maximum text length is set to 32767 characters.

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

See also text and maxLength.

TQLineEdit::TQLineEdit ( const TQString & contents, TQWidget * parent, const char * name = 0 )
Constructs a line edit containing the text contents.

The cursor position is set to the end of the line and the maximum text length to 32767 characters.

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

See also text and maxLength.

TQLineEdit::TQLineEdit ( const TQString & contents, const TQString & inputMask, TQWidget * parent, const char * name = 0 )
Constructs a line edit with an input inputMask and the text contents.

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

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

See also setMask() and text.

TQLineEdit::~TQLineEdit ()
Destroys the line edit.

int TQLineEdit::alignment () const
Returns the alignment of the line edit. See the "alignment" property for details.

void TQLineEdit::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.

See also del().

int TQLineEdit::characterAt ( int xpos, TQChar * chr ) const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

void TQLineEdit::clear () [virtual slot]
Clears the contents of the line edit.

void TQLineEdit::clearModified ()
Resets the modified flag to false.

See also modified.

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

void TQLineEdit::copy () const [virtual slot]
Copies the selected text to the clipboard, if there is any, and if echoMode() is Normal.

See also cut() and paste().

TQPopupMenu * TQLineEdit::createPopupMenu () [virtual protected]
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.

void TQLineEdit::cursorBackward ( bool mark, int steps = 1 )
Moves the cursor back steps characters. If mark is true each character moved over is added to the selection; if mark is false the selection is cleared.

See also cursorForward().

void TQLineEdit::cursorForward ( bool mark, int steps = 1 )
Moves the cursor forward steps characters. If mark is true each character moved over is added to the selection; if mark is false the selection is cleared.

See also cursorBackward().

int TQLineEdit::cursorPosition () const
Returns the current cursor position for this line edit. See the "cursorPosition" property for details.

void TQLineEdit::cursorWordBackward ( bool mark )
Moves the cursor one word backward. If mark is true, the word is also selected.

See also cursorWordForward().

void TQLineEdit::cursorWordForward ( bool mark )
Moves the cursor one word forward. If mark is true, the word is also selected.

See also cursorWordBackward().

void TQLineEdit::cut () [virtual slot]
Copies the selected text to the clipboard and deletes it, if there is any, and if echoMode() is Normal.

If the current validator disallows deleting the selected text, cut() will copy without deleting.

See also copy(), paste(), and setValidator().

void TQLineEdit::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.

See also backspace().

void TQLineEdit::deselect () [virtual slot]
Deselects any selected text.

See also setSelection() and selectAll().

TQString TQLineEdit::displayText () const
Returns the displayed text. See the "displayText" property for details.

bool TQLineEdit::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.

EchoMode TQLineEdit::echoMode () const
Returns the line edit's echo mode. See the "echoMode" property for details.

bool TQLineEdit::edited () const
Returns true if the line edit has been edited. Use modified instead; otherwise returns false. See the "edited" property for details.

void TQLineEdit::end ( bool mark )
Moves the text cursor to the end of the line unless it is already there. If mark is true, text is selected towards the last position; otherwise, any selected text is unselected if the cursor is moved.

See also home().

bool TQLineEdit::frame () const
Returns true if the line edit draws itself with a frame; otherwise returns false. See the "frame" property for details.

bool TQLineEdit::getSelection ( int * start, int * end )
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. use selectedText(), selectionStart()

bool TQLineEdit::hasAcceptableInput () const
Returns true if the input satisfies the inputMask and the validator; otherwise returns false. See the "acceptableInput" property for details.

bool TQLineEdit::hasSelectedText () const
Returns true if there is any text selected; otherwise returns false. See the "hasSelectedText" property for details.

void TQLineEdit::home ( bool mark )
Moves the text cursor to the beginning of the line unless it is already there. If mark is true, text is selected towards the first position; otherwise, any selected text is unselected if the cursor is moved.

See also end().

TQString TQLineEdit::inputMask () const
Returns the validation input mask. See the "inputMask" property for details.

void TQLineEdit::insert ( const TQString & newText ) [virtual slot]
Deletes any selected text, inserts newText, and validates the result. If it is valid, it sets it as the new contents of the line edit.

bool TQLineEdit::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.

bool TQLineEdit::isReadOnly () const
Returns true if the line edit is read only; otherwise returns false. See the "readOnly" property for details.

bool TQLineEdit::isRedoAvailable () const
Returns true if redo is available; otherwise returns false. See the "redoAvailable" property for details.

bool TQLineEdit::isUndoAvailable () const
Returns true if undo is available; otherwise returns false. See the "undoAvailable" property for details.

void TQLineEdit::keyPressEvent ( TQKeyEvent * e ) [virtual protected]
Converts key press event e into a line edit action.

If Return or Enter is pressed and the current text is valid (or can be made valid by the validator), the signal returnPressed() is emitted.

The default key bindings are listed in the detailed description.

Reimplemented from TQWidget.

void TQLineEdit::lostFocus () [signal]
This signal is emitted when the line edit has lost focus.

See also focus, TQWidget::focusInEvent(), and TQWidget::focusOutEvent().

int TQLineEdit::maxLength () const
Returns the maximum permitted length of the text. See the "maxLength" property for details.

TQSize TQLineEdit::minimumSizeHint () const [virtual]
Returns a minimum size for the line edit.

The width returned is enough for at least one character.

Reimplemented from TQWidget.

void TQLineEdit::paste () [virtual slot]
Inserts the clipboard's text at the cursor position, deleting any selected text, providing the line edit is not read-only.

If the end result would not be acceptable to the current validator, nothing happens.

See also copy() and cut().

void TQLineEdit::redo () [virtual slot]
Redoes the last operation if redo is available.

void TQLineEdit::returnPressed () [signal]
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 Acceptable.

Example: popup/popup.cpp.

void TQLineEdit::selectAll () [virtual slot]
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.

See also setSelection() and deselect().

TQString TQLineEdit::selectedText () const
Returns the selected text. See the "selectedText" property for details.

void TQLineEdit::selectionChanged () [signal]
This signal is emitted whenever the selection changes.

See also hasSelectedText and selectedText.

int TQLineEdit::selectionStart () const
selectionStart() returns the index of the first selected character in the line edit or -1 if no text is selected.

See also selectedText.

void TQLineEdit::setAlignment ( int flag ) [virtual slot]
Sets the alignment of the line edit to flag. See the "alignment" property for details.

void TQLineEdit::setCursorPosition ( int ) [virtual slot]
Sets the current cursor position for this line edit. See the "cursorPosition" property for details.

void TQLineEdit::setDragEnabled ( bool b ) [virtual slot]
Sets whether the lineedit starts a drag if the user presses and moves the mouse on some selected text to b. See the "dragEnabled" property for details.

void TQLineEdit::setEchoMode ( EchoMode ) [virtual slot]
Sets the line edit's echo mode. See the "echoMode" property for details.

void TQLineEdit::setEdited ( bool )
Sets whether the line edit has been edited. Use modified instead. See the "edited" property for details.

void TQLineEdit::setFrame ( bool ) [virtual slot]
Sets whether the line edit draws itself with a frame. See the "frame" property for details.

void TQLineEdit::setInputMask ( const TQString & inputMask )
Sets the validation input mask to inputMask. See the "inputMask" property for details.

void TQLineEdit::setMaxLength ( int ) [virtual slot]
Sets the maximum permitted length of the text. See the "maxLength" property for details.

void TQLineEdit::setReadOnly ( bool ) [virtual slot]
Sets whether the line edit is read only. See the "readOnly" property for details.

void TQLineEdit::setSelection ( int start, int length ) [virtual slot]
Selects text from position start and for length characters.

Note that this function sets the cursor's position to the end of the selection regardless of its current position.

See also deselect(), selectAll(), getSelection(), cursorForward(), and cursorBackward().

void TQLineEdit::setText ( const TQString & ) [virtual slot]
Sets the line edit's text. See the "text" property for details.

void TQLineEdit::setValidator ( const TQValidator * v ) [virtual slot]
Sets this line edit to only accept input that the validator, v, will accept. This allows you to place any arbitrary constraints on the text which may be entered.

If v == 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()).

See also validator(), TQIntValidator, TQDoubleValidator, and TQRegExpValidator.

Examples:

TQSize TQLineEdit::sizeHint () const [virtual]
Returns a recommended size for the widget.

The width returned, in pixels, is usually enough for about 15 to 20 characters.

Example: addressbook/centralwidget.cpp.

TQString TQLineEdit::text () const
Returns the line edit's text. See the "text" property for details.

void TQLineEdit::textChanged ( const TQString & ) [signal]
This signal is emitted whenever the text changes. The argument is the new text.

Examples:

void TQLineEdit::undo () [virtual slot]
Undoes the last operation if undo is available. Deselects any current selection, and updates the selection start to the current cursor position.

bool TQLineEdit::validateAndSet ( const TQString & newText, int newPos, int newMarkAnchor, int newMarkDrag )
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. Use setText(), setCursorPosition() and setSelection() instead.

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

See also setValidator().

Example: wizard/wizard.cpp.

  Property Documentation

bool acceptableInput
This property holds whether the input satisfies the inputMask and the validator.

Get this property's value with hasAcceptableInput().

See also inputMask and setValidator().

Alignment alignment
This property holds the alignment of the line edit.

Possible Values are TQt::AlignAuto, TQt::AlignLeft, TQt::AlignRight and TQt::AlignHCenter.

Attempting to set the alignment to an illegal flag combination does nothing.

See also TQt::AlignmentFlags.

Set this property's value with setAlignment() and get this property's value with alignment().

int cursorPosition
This property holds the current cursor position for this line edit.

Setting the cursor position causes a repaint when appropriate.

Set this property's value with setCursorPosition() and get this property's value with cursorPosition().

TQString displayText
This property holds the displayed text.

If EchoMode is Normal this returns the same as text(); if EchoMode is Password it returns a string of asterisks text().length() characters long, e.g. "******"; if EchoMode is NoEcho returns an empty string, "".

See also echoMode, text, and EchoMode.

Get this property's value with displayText().

bool dragEnabled
This property holds whether the lineedit starts a drag if the user presses and moves the mouse on some selected text.

Set this property's value with setDragEnabled() and get this property's value with dragEnabled().

EchoMode echoMode
This property holds the line edit's echo mode.

The initial setting is Normal, but TQLineEdit also supports NoEcho and Password modes.

The widget's display and the ability to copy or drag the text is affected by this setting.

See also EchoMode and displayText.

Set this property's value with setEchoMode() and get this property's value with echoMode().

bool edited
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

This property holds whether the line edit has been edited. Use modified instead.

Set this property's value with setEdited() and get this property's value with edited().

bool frame
This property holds whether the line edit draws itself with a frame.

If enabled (the default) the line edit draws itself inside a two-pixel frame, otherwise the line edit draws itself without any frame.

Set this property's value with setFrame() and get this property's value with frame().

bool hasSelectedText
This property holds whether there is any text selected.

hasSelectedText() returns true if some or all of the text has been selected by the user; otherwise returns false.

See also selectedText.

Get this property's value with hasSelectedText().

TQString inputMask
This property holds the validation input mask.

If no mask is set, inputMask() returns TQString::null.

Sets the TQLineEdit's validation mask. Validators can be used instead of, or in conjunction with masks; see setValidator().

Unset the mask and return to normal TQLineEdit operation by passing an empty string ("") or just calling setInputMask() with no arguments.

The mask format understands these mask characters: <center>.nf
</center>

The mask consists of a string of mask characters and separators, optionally followed by a semi-colon and the character used for blanks: the blank characters are always removed from the text after editing. The default blank character is space.

Examples: <center>.nf
</center>

To get range control (e.g. for an IP address) use masks together with validators.

See also maxLength.

Set this property's value with setInputMask() and get this property's value with inputMask().

int maxLength
This property holds the maximum permitted length of the text.

If the text is too long, it is truncated at the limit.

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.

If the line edit has an input mask, the mask defines the maximum string length.

See also inputMask.

Set this property's value with setMaxLength() and get this property's value with maxLength().

bool modified
This property holds whether the line edit's contents has been modified by the user.

The modified flag is never read by TQLineEdit; it has a default value of false and is changed to true whenever the user changes the line edit's contents.

This is useful for things that need to provide a default value but do not start out knowing what the default should be (perhaps it depends on other fields on the form). Start the line edit without the best default, and when the default is known, if modified() returns false (the user hasn't entered any text), insert the default value.

Calling clearModified() or setText() resets the modified flag to false.

Get this property's value with isModified().

bool readOnly
This property holds whether the line edit is read only.

In read-only mode, the user can still copy the text to the clipboard or drag-and-drop the text (if echoMode() is Normal), but cannot edit it.

TQLineEdit does not show a cursor in read-only mode.

See also enabled.

Set this property's value with setReadOnly() and get this property's value with isReadOnly().

bool redoAvailable
This property holds whether redo is available.

Get this property's value with isRedoAvailable().

TQString selectedText
This property holds the selected text.

If there is no selected text this property's value is TQString::null.

See also hasSelectedText.

Get this property's value with selectedText().

TQString text
This property holds the line edit's text.

Note that setting this property clears the selection, clears the undo/redo history, moves the cursor to the end of the line and resets the modified property to false. The text is not validated when inserted with setText().

The text is truncated to maxLength() length.

See also insert().

Set this property's value with setText() and get this property's value with text().

bool undoAvailable
This property holds whether undo is available.

Get this property's value with isUndoAvailable().

SEE ALSO
http://doc.trolltech.com/tqlineedit.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.

The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (tqlineedit.3qt) and the Qt version (3.3.8).