Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Properties | Private Member Functions | Friends | Related Functions

QLineEdit Class Reference

The QLineEdit widget is a one-line text editor. More...

Inheritance diagram for QLineEdit:
Inheritance graph
[legend]
Collaboration diagram for QLineEdit:
Collaboration graph
[legend]

List of all members.

Public Types

enum  EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit }
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }

Public Slots

void clear ()
bool close ()
void copy () const
void cut ()
void hide ()
void lower ()
void paste ()
void raise ()
void redo ()
void repaint ()
void selectAll ()
void setDisabled (bool)
void setEnabled (bool)
void setFocus ()
void setHidden (bool hidden)
QT_MOC_COMPAT void setShown (bool shown)
void setStyleSheet (const QString &styleSheet)
void setText (const QString &)
virtual void setVisible (bool visible)
void setWindowModified (bool)
void setWindowTitle (const QString &)
void show ()
void showFullScreen ()
void showMaximized ()
void showMinimized ()
void showNormal ()
void undo ()
void update ()

Signals

void cursorPositionChanged (int, int)
void customContextMenuRequested (const QPoint &pos)
void editingFinished ()
void returnPressed ()
void selectionChanged ()
void textChanged (const QString &)
void textEdited (const QString &)

Public Member Functions

bool acceptDrops () const
QString accessibleDescription () const
QString accessibleName () const
QList< QAction * > actions () const
void activateWindow ()
void addAction (QAction *action)
void addActions (QList< QAction * > actions)
void adjustSize ()
Qt::Alignment alignment () const
bool autoFillBackground () const
QPalette::ColorRole backgroundRole () const
void backspace ()
QSize baseSize () const
QWidgetchildAt (int x, int y) const
QWidgetchildAt (const QPoint &p) const
QRect childrenRect () const
QRegion childrenRegion () const
void clearFocus ()
void clearMask ()
QCompletercompleter () const
QRect contentsRect () const
Qt::ContextMenuPolicy contextMenuPolicy () const
QMenucreateStandardContextMenu ()
void createWinId ()
QCursor cursor () const
void cursorBackward (bool mark, int steps=1)
void cursorForward (bool mark, int steps=1)
int cursorPosition () const
int cursorPositionAt (const QPoint &pos)
void cursorWordBackward (bool mark)
void cursorWordForward (bool mark)
void del ()
int depth () const
void deselect ()
int devType () const
QString displayText () const
bool dragEnabled () const
EchoMode echoMode () const
WId effectiveWinId () const
void end (bool mark)
void ensurePolished () const
bool event (QEvent *)
Qt::FocusPolicy focusPolicy () const
QWidgetfocusProxy () const
QWidgetfocusWidget () const
const QFontfont () const
QFontInfo fontInfo () const
QFontMetrics fontMetrics () const
QPalette::ColorRole foregroundRole () const
QRect frameGeometry () const
QSize frameSize () const
const QRectgeometry () const
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
void getTextMargins (int *left, int *top, int *right, int *bottom) const
void grabKeyboard ()
void grabMouse ()
void grabMouse (const QCursor &)
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
QGraphicsProxyWidgetgraphicsProxyWidget () const
Qt::HANDLE handle () const
bool hasAcceptableInput () const
bool hasFocus () const
bool hasFrame () const
bool hasMouseTracking () const
bool hasSelectedText () const
int height () const
virtual int heightForWidth (int) const
int heightMM () const
void home (bool mark)
QInputContextinputContext ()
QString inputMask () const
QVariant inputMethodQuery (Qt::InputMethodQuery) const
void insert (const QString &)
void insertAction (QAction *before, QAction *action)
void insertActions (QAction *before, QList< QAction * > actions)
WId internalWinId () const
bool isActiveWindow () const
bool isAncestorOf (const QWidget *child) const
bool isEnabled () const
bool isEnabledTo (QWidget *) const
bool isEnabledToTLW () const
bool isFullScreen () const
bool isHidden () const
bool isLeftToRight () const
bool isMaximized () const
bool isMinimized () const
bool isModal () const
bool isModified () const
bool isReadOnly () const
bool isRedoAvailable () const
bool isRightToLeft () const
bool isTopLevel () const
bool isUndoAvailable () const
bool isVisible () const
bool isVisibleTo (QWidget *) const
bool isWindow () const
bool isWindowModified () const
QLayoutlayout () const
Qt::LayoutDirection layoutDirection () const
QLocale locale () const
int logicalDpiX () const
int logicalDpiY () const
QPoint mapFrom (QWidget *, const QPoint &) const
QPoint mapFromGlobal (const QPoint &) const
QPoint mapFromParent (const QPoint &) const
QPoint mapTo (QWidget *, const QPoint &) const
QPoint mapToGlobal (const QPoint &) const
QPoint mapToParent (const QPoint &) const
QRegion mask () const
int maximumHeight () const
QSize maximumSize () const
int maximumWidth () const
int maxLength () const
int minimumHeight () const
QSize minimumSize () const
QSize minimumSizeHint () const
int minimumWidth () const
void move (const QPoint &)
void move (int x, int y)
QWidgetnativeParentWidget () const
QWidgetnextInFocusChain () const
QRect normalGeometry () const
int numColors () const
void overrideWindowFlags (Qt::WindowFlags type)
void overrideWindowState (Qt::WindowStates state)
QPaintEnginepaintEngine () const
bool paintingActive () const
const QPalettepalette () const
QWidgetparentWidget () const
int physicalDpiX () const
int physicalDpiY () const
QPoint pos () const
 QLineEdit (const QString &, QWidget *parent=0)
 QLineEdit (QWidget *parent=0)
QRect rect () const
void releaseKeyboard ()
void releaseMouse ()
void releaseShortcut (int id)
void removeAction (QAction *action)
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
void repaint (int x, int y, int w, int h)
void repaint (const QRect &)
void repaint (const QRegion &)
void resize (const QSize &)
void resize (int w, int h)
bool restoreGeometry (const QByteArray &geometry)
QByteArray saveGeometry () const
void scroll (int dx, int dy)
void scroll (int dx, int dy, const QRect &)
QString selectedText () const
int selectionStart () const
void setAcceptDrops (bool on)
void setAccessibleDescription (const QString &description)
void setAccessibleName (const QString &name)
void setAlignment (Qt::Alignment flag)
void setAttribute (Qt::WidgetAttribute, bool on=true)
void setAutoFillBackground (bool enabled)
void setBackgroundRole (QPalette::ColorRole)
void setBaseSize (int basew, int baseh)
void setBaseSize (const QSize &)
void setCompleter (QCompleter *completer)
void setContentsMargins (int left, int top, int right, int bottom)
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
void setCursor (const QCursor &)
void setCursorPosition (int)
void setDragEnabled (bool b)
void setEchoMode (EchoMode)
void setFixedHeight (int h)
void setFixedSize (int w, int h)
void setFixedSize (const QSize &)
void setFixedWidth (int w)
void setFocus (Qt::FocusReason reason)
void setFocusPolicy (Qt::FocusPolicy policy)
void setFocusProxy (QWidget *)
void setFont (const QFont &)
void setForegroundRole (QPalette::ColorRole)
void setFrame (bool)
void setGeometry (const QRect &)
void setGeometry (int x, int y, int w, int h)
void setInputContext (QInputContext *)
void setInputMask (const QString &inputMask)
void setLayout (QLayout *)
void setLayoutDirection (Qt::LayoutDirection direction)
void setLocale (const QLocale &locale)
void setMask (const QBitmap &)
void setMask (const QRegion &)
void setMaximumHeight (int maxh)
void setMaximumSize (const QSize &)
void setMaximumSize (int maxw, int maxh)
void setMaximumWidth (int maxw)
void setMaxLength (int)
void setMinimumHeight (int minh)
void setMinimumSize (const QSize &)
void setMinimumSize (int minw, int minh)
void setMinimumWidth (int minw)
void setModified (bool)
void setMouseTracking (bool enable)
void setPalette (const QPalette &)
void setParent (QWidget *parent, Qt::WindowFlags f)
void setParent (QWidget *parent)
void setReadOnly (bool)
void setSelection (int, int)
void setShortcutAutoRepeat (int id, bool enable=true)
void setShortcutEnabled (int id, bool enable=true)
void setSizeIncrement (int w, int h)
void setSizeIncrement (const QSize &)
void setSizePolicy (QSizePolicy)
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
void setStatusTip (const QString &)
void setStyle (QStyle *)
void setTextMargins (int left, int top, int right, int bottom)
void setToolTip (const QString &)
void setUpdatesEnabled (bool enable)
void setValidator (const QValidator *)
void setWhatsThis (const QString &)
void setWindowFilePath (const QString &filePath)
void setWindowFlags (Qt::WindowFlags type)
void setWindowIcon (const QIcon &icon)
void setWindowIconText (const QString &)
void setWindowModality (Qt::WindowModality windowModality)
void setWindowOpacity (qreal level)
void setWindowRole (const QString &)
void setWindowState (Qt::WindowStates state)
void setWindowSurface (QWindowSurface *surface)
QSize size () const
QSize sizeHint () const
QSize sizeIncrement () const
QSizePolicy sizePolicy () const
void stackUnder (QWidget *)
QString statusTip () const
QStylestyle () const
QString styleSheet () const
bool testAttribute (Qt::WidgetAttribute) const
QString text () const
QString toolTip () const
QWidgettopLevelWidget () const
bool underMouse () const
void unsetCursor ()
void unsetLayoutDirection ()
void unsetLocale ()
void update (int x, int y, int w, int h)
void update (const QRegion &)
void update (const QRect &)
void updateGeometry ()
bool updatesEnabled () const
const QValidatorvalidator () const
QRegion visibleRegion () const
QString whatsThis () const
int width () const
int widthMM () const
QWidgetwindow () const
QString windowFilePath () const
Qt::WindowFlags windowFlags () const
QIcon windowIcon () const
QString windowIconText () const
Qt::WindowModality windowModality () const
qreal windowOpacity () const
QString windowRole () const
Qt::WindowStates windowState () const
QWindowSurfacewindowSurface () const
QString windowTitle () const
Qt::WindowType windowType () const
WId winId () const
int x () const
int y () const
 ~QLineEdit ()

Static Public Member Functions

static QWidgetfind (WId)
static QWidgetkeyboardGrabber ()
static QWidgetmouseGrabber ()
static void setTabOrder (QWidget *, QWidget *)

Protected Slots

void updateMicroFocus ()

Protected Member Functions

virtual void actionEvent (QActionEvent *)
void changeEvent (QEvent *)
virtual void closeEvent (QCloseEvent *)
void contextMenuEvent (QContextMenuEvent *)
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
QRect cursorRect () const
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
void dragEnterEvent (QDragEnterEvent *)
void dragLeaveEvent (QDragLeaveEvent *e)
void dragMoveEvent (QDragMoveEvent *e)
void dropEvent (QDropEvent *)
virtual void enabledChange (bool)
virtual void enterEvent (QEvent *)
void focusInEvent (QFocusEvent *)
bool focusNextChild ()
virtual bool focusNextPrevChild (bool next)
void focusOutEvent (QFocusEvent *)
bool focusPreviousChild ()
virtual void fontChange (const QFont &)
virtual void hideEvent (QHideEvent *)
void initStyleOption (QStyleOptionFrame *option) const
void inputMethodEvent (QInputMethodEvent *)
void keyPressEvent (QKeyEvent *)
virtual void keyReleaseEvent (QKeyEvent *)
virtual void languageChange ()
virtual void leaveEvent (QEvent *)
int metric (PaintDeviceMetric) const
void mouseDoubleClickEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void mousePressEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
virtual void moveEvent (QMoveEvent *)
void paintEvent (QPaintEvent *)
virtual void paletteChange (const QPalette &)
void resetInputContext ()
virtual void resizeEvent (QResizeEvent *)
virtual void showEvent (QShowEvent *)
virtual void styleChange (QStyle &)
virtual void tabletEvent (QTabletEvent *)
virtual void wheelEvent (QWheelEvent *)
virtual void windowActivationChange (bool)

Protected Attributes

ushort painters

Properties

bool acceptableInput
 whether the input satisfies the inputMask and the validator.
bool acceptDrops
 whether drop events are enabled for this widget
QString accessibleDescription
 the widget's description as seen by assistive technologies
QString accessibleName
 the widget's name as seen by assistive technologies
Qt::Alignment alignment
 the alignment of the line edit
bool autoFillBackground
 whether the widget background is filled automatically
QSize baseSize
 the base size of the widget
QRect childrenRect
 the bounding rectangle of the widget's children
QRegion childrenRegion
 the combined region occupied by the widget's children
Qt::ContextMenuPolicy contextMenuPolicy
 how the widget shows a context menu
QCursor cursor
 the cursor shape for this widget
int cursorPosition
 the current cursor position for this line edit
QString displayText
 the displayed text
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 enabled
 whether the widget is enabled
bool focus
 whether this widget (or its focus proxy) has the keyboard input focus
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus
QFont font
 the font currently set for the widget
bool frame
 whether the line edit draws itself with a frame
QRect frameGeometry
 geometry of the widget relative to its parent including any window frame
QSize frameSize
 the size of the widget including any window frame
bool fullScreen
 whether the widget is shown in full screen mode
QRect geometry
 the geometry of the widget relative to its parent and excluding the window frame
bool hasSelectedText
 whether there is any text selected
int height
 the height of the widget excluding any window frame
QString inputMask
 The validation input mask.
bool isActiveWindow
 whether this widget's window is the active window
Qt::LayoutDirection layoutDirection
 the layout direction for this widget
QLocale locale
 the widget's locale
bool maximized
 whether this widget is maximized
int maximumHeight
 the widget's maximum height in pixels
QSize maximumSize
 the widget's maximum size in pixels
int maximumWidth
 the widget's maximum width in pixels
int maxLength
 the maximum permitted length of the text
bool minimized
 whether this widget is minimized (iconified)
int minimumHeight
 the widget's minimum height in pixels
QSize minimumSize
 the widget's minimum size
QSize minimumSizeHint
 the recommended minimum size for the widget
int minimumWidth
 the widget's minimum width in pixels
bool modal
 whether the widget is a modal widget
bool modified
 whether the line edit's contents has been modified by the user
bool mouseTracking
 whether mouse tracking is enabled for the widget
QRect normalGeometry
 the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget
QPalette palette
 the widget's palette
QPoint pos
 the position of the widget within its parent widget
bool readOnly
 whether the line edit is read only.
QRect rect
 the internal geometry of the widget excluding any window frame
bool redoAvailable
 whether redo is available
QString selectedText
 the selected text
QSize size
 the size of the widget excluding any window frame
QSize sizeHint
 the recommended size for the widget
QSize sizeIncrement
 the size increment of the widget
QSizePolicy sizePolicy
 the default layout behavior of the widget
QString statusTip
 the widget's status tip
QString styleSheet
 the widget's style sheet
QString text
 the line edit's text
QString toolTip
 the widget's tooltip
bool undoAvailable
 whether undo is available
bool updatesEnabled
 whether updates are enabled
bool visible
 whether the widget is visible
QString whatsThis
 the widget's What's This help text.
int width
 the width of the widget excluding any window frame
QString windowFilePath
 the file path associated with a widget
QIcon windowIcon
 the widget's icon
QString windowIconText
 the widget's icon text
Qt::WindowModality windowModality
 which windows are blocked by the modal widget
bool windowModified
 whether the document shown in the window has unsaved changes
double windowOpacity
 The level of opacity for the window.
QString windowTitle
 the window title (caption)
int x
 the x coordinate of the widget relative to its parent including any window frame
int y
 the y coordinate of the widget relative to its parent and including any window frame

Private Member Functions

void void _q_deleteSelected ()) Q_PRIVATE_SLOT(d_func()
void _q_handleWindowActivate ()) Q_PRIVATE_SLOT(d_func()
 Q_PRIVATE_SLOT (d_func(), void _q_clipboardChanged()) Q_PRIVATE_SLOT(d_func()

Friends

class QAbstractSpinBox

Related Functions

(Note that these are not member functions.)


 QT_END_NAMESPACEWId
const Q_GUI_EXPORT QX11Infoqt_x11Info (const QPaintDevice *pd)
 QWidgetList

Detailed Description

The QLineEdit 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 QTextEdit 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 text changes other than by calling setText() the textEdited() signal is emitted; when the cursor is moved the cursorPositionChanged() signal is emitted; and when the Return or Enter key is pressed the returnPressed() signal is emitted.

When editing is finished, either because the line edit lost focus or Return/Enter is pressed the editingFinished() signal is emitted.

Note that if there is a validator set on the line edit, the returnPressed()/editingFinished() signals will only be emitted if the validator returns QValidator::Acceptable.

By default, QLineEdits 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. desc Keypress Action Left Arrow Moves the cursor one character to the left. Shift+Left Arrow Moves and selects text one character to the left. Right Arrow Moves the cursor one character to the right. Shift+Right Arrow Moves and selects text one character to the right. Home Moves the cursor to the beginning of the line. End Moves the cursor to the end of the line. Backspace Deletes the character to the left of the cursor. Ctrl+Backspace Deletes the word to the left of the cursor. Delete Deletes the character to the right of the cursor. Ctrl+Delete Deletes the word to the right of the cursor. Ctrl+A Select all. Ctrl+C Copies the selected text to the clipboard. Ctrl+Insert Copies the selected text to the clipboard. Ctrl+K Deletes to the end of the line. Ctrl+V Pastes the clipboard text into line edit. Shift+Insert Pastes the clipboard text into line edit. Ctrl+X Deletes the selected text and copies it to the clipboard. Shift+Delete Deletes the selected text and copies it to the clipboard. Ctrl+Z Undoes the last operation. Ctrl+Y Redoes the last undone operation.

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

100% macintosh-lineedit.png Screenshot of a Macintosh style line edit A line edit shown in the {Macintosh Style Widget Gallery}{Macintosh widget style}. windows-lineedit.png Screenshot of a Windows XP style line edit A line edit shown in the {Windows XP Style Widget Gallery}{Windows XP widget style}. plastique-lineedit.png Screenshot of a Plastique style line edit A line edit shown in the {Plastique Style Widget Gallery}{Plastique widget style}.

See also:
QTextEdit, QLabel, QComboBox, {fowler}{GUI Design Handbook: Field, Entry}, {Line Edits Example}

Definition at line 64 of file qlineedit.h.


The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index