source: trunk/src/gui/widgets/qlineedit.cpp@ 769

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

File size: 64.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qlineedit.h"
43#include "qlineedit_p.h"
44
45#ifndef QT_NO_LINEEDIT
46#include "qaction.h"
47#include "qapplication.h"
48#include "qclipboard.h"
49#include "qdrag.h"
50#include "qdrawutil.h"
51#include "qevent.h"
52#include "qfontmetrics.h"
53#include "qmenu.h"
54#include "qpainter.h"
55#include "qpixmap.h"
56#include "qpointer.h"
57#include "qstringlist.h"
58#include "qstyle.h"
59#include "qstyleoption.h"
60#include "qtimer.h"
61#include "qvalidator.h"
62#include "qvariant.h"
63#include "qvector.h"
64#include "qwhatsthis.h"
65#include "qdebug.h"
66#include "qtextedit.h"
67#include <private/qtextedit_p.h>
68#ifndef QT_NO_ACCESSIBILITY
69#include "qaccessible.h"
70#endif
71#ifndef QT_NO_IM
72#include "qinputcontext.h"
73#include "qlist.h"
74#endif
75#include "qabstractitemview.h"
76#include "private/qstylesheetstyle_p.h"
77
78#ifndef QT_NO_SHORTCUT
79#include "private/qapplication_p.h"
80#include "private/qshortcutmap_p.h"
81#include "qkeysequence.h"
82#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString())
83#else
84#define ACCEL_KEY(k) QString()
85#endif
86
87#include <limits.h>
88
89QT_BEGIN_NAMESPACE
90
91#ifdef Q_WS_MAC
92extern void qt_mac_secure_keyboard(bool); //qapplication_mac.cpp
93#endif
94
95/*!
96 Initialize \a option with the values from this QLineEdit. This method
97 is useful for subclasses when they need a QStyleOptionFrame or QStyleOptionFrameV2, but don't want
98 to fill in all the information themselves. This function will check the version
99 of the QStyleOptionFrame and fill in the additional values for a
100 QStyleOptionFrameV2.
101
102 \sa QStyleOption::initFrom()
103*/
104void QLineEdit::initStyleOption(QStyleOptionFrame *option) const
105{
106 if (!option)
107 return;
108
109 Q_D(const QLineEdit);
110 option->initFrom(this);
111 option->rect = contentsRect();
112 option->lineWidth = d->frame ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this)
113 : 0;
114 option->midLineWidth = 0;
115 option->state |= QStyle::State_Sunken;
116 if (d->control->isReadOnly())
117 option->state |= QStyle::State_ReadOnly;
118#ifdef QT_KEYPAD_NAVIGATION
119 if (hasEditFocus())
120 option->state |= QStyle::State_HasEditFocus;
121#endif
122 if (QStyleOptionFrameV2 *optionV2 = qstyleoption_cast<QStyleOptionFrameV2 *>(option))
123 optionV2->features = QStyleOptionFrameV2::None;
124}
125
126/*!
127 \class QLineEdit
128 \brief The QLineEdit widget is a one-line text editor.
129
130 \ingroup basicwidgets
131
132
133 A line edit allows the user to enter and edit a single line of
134 plain text with a useful collection of editing functions,
135 including undo and redo, cut and paste, and drag and drop.
136
137 By changing the echoMode() of a line edit, it can also be used as
138 a "write-only" field, for inputs such as passwords.
139
140 The length of the text can be constrained to maxLength(). The text
141 can be arbitrarily constrained using a validator() or an
142 inputMask(), or both.
143
144 A related class is QTextEdit which allows multi-line, rich text
145 editing.
146
147 You can change the text with setText() or insert(). The text is
148 retrieved with text(); the displayed text (which may be different,
149 see \l{EchoMode}) is retrieved with displayText(). Text can be
150 selected with setSelection() or selectAll(), and the selection can
151 be cut(), copy()ied and paste()d. The text can be aligned with
152 setAlignment().
153
154 When the text changes the textChanged() signal is emitted; when
155 the text changes other than by calling setText() the textEdited()
156 signal is emitted; when the cursor is moved the
157 cursorPositionChanged() signal is emitted; and when the Return or
158 Enter key is pressed the returnPressed() signal is emitted.
159
160 When editing is finished, either because the line edit lost focus
161 or Return/Enter is pressed the editingFinished() signal is
162 emitted.
163
164 Note that if there is a validator set on the line edit, the
165 returnPressed()/editingFinished() signals will only be emitted if
166 the validator returns QValidator::Acceptable.
167
168 By default, QLineEdits have a frame as specified by the Windows
169 and Motif style guides; you can turn it off by calling
170 setFrame(false).
171
172 The default key bindings are described below. The line edit also
173 provides a context menu (usually invoked by a right mouse click)
174 that presents some of these editing options.
175 \target desc
176 \table
177 \header \i Keypress \i Action
178 \row \i Left Arrow \i Moves the cursor one character to the left.
179 \row \i Shift+Left Arrow \i Moves and selects text one character to the left.
180 \row \i Right Arrow \i Moves the cursor one character to the right.
181 \row \i Shift+Right Arrow \i Moves and selects text one character to the right.
182 \row \i Home \i Moves the cursor to the beginning of the line.
183 \row \i End \i Moves the cursor to the end of the line.
184 \row \i Backspace \i Deletes the character to the left of the cursor.
185 \row \i Ctrl+Backspace \i Deletes the word to the left of the cursor.
186 \row \i Delete \i Deletes the character to the right of the cursor.
187 \row \i Ctrl+Delete \i Deletes the word to the right of the cursor.
188 \row \i Ctrl+A \i Select all.
189 \row \i Ctrl+C \i Copies the selected text to the clipboard.
190 \row \i Ctrl+Insert \i Copies the selected text to the clipboard.
191 \row \i Ctrl+K \i Deletes to the end of the line.
192 \row \i Ctrl+V \i Pastes the clipboard text into line edit.
193 \row \i Shift+Insert \i Pastes the clipboard text into line edit.
194 \row \i Ctrl+X \i Deletes the selected text and copies it to the clipboard.
195 \row \i Shift+Delete \i Deletes the selected text and copies it to the clipboard.
196 \row \i Ctrl+Z \i Undoes the last operation.
197 \row \i Ctrl+Y \i Redoes the last undone operation.
198 \endtable
199
200 Any other key sequence that represents a valid character, will
201 cause the character to be inserted into the line edit.
202
203 \table 100%
204 \row \o \inlineimage macintosh-lineedit.png Screenshot of a Macintosh style line edit
205 \o A line edit shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}.
206 \row \o \inlineimage windows-lineedit.png Screenshot of a Windows XP style line edit
207 \o A line edit shown in the \l{Windows XP Style Widget Gallery}{Windows XP widget style}.
208 \row \o \inlineimage plastique-lineedit.png Screenshot of a Plastique style line edit
209 \o A line edit shown in the \l{Plastique Style Widget Gallery}{Plastique widget style}.
210 \endtable
211
212 \sa QTextEdit, QLabel, QComboBox, {fowler}{GUI Design Handbook: Field, Entry}, {Line Edits Example}
213*/
214
215
216/*!
217 \fn void QLineEdit::textChanged(const QString &text)
218
219 This signal is emitted whenever the text changes. The \a text
220 argument is the new text.
221
222 Unlike textEdited(), this signal is also emitted when the text is
223 changed programmatically, for example, by calling setText().
224*/
225
226/*!
227 \fn void QLineEdit::textEdited(const QString &text)
228
229 This signal is emitted whenever the text is edited. The \a text
230 argument is the next text.
231
232 Unlike textChanged(), this signal is not emitted when the text is
233 changed programmatically, for example, by calling setText().
234*/
235
236/*!
237 \fn void QLineEdit::cursorPositionChanged(int old, int new)
238
239 This signal is emitted whenever the cursor moves. The previous
240 position is given by \a old, and the new position by \a new.
241
242 \sa setCursorPosition(), cursorPosition()
243*/
244
245/*!
246 \fn void QLineEdit::selectionChanged()
247
248 This signal is emitted whenever the selection changes.
249
250 \sa hasSelectedText(), selectedText()
251*/
252
253/*!
254 Constructs a line edit with no text.
255
256 The maximum text length is set to 32767 characters.
257
258 The \a parent argument is sent to the QWidget constructor.
259
260 \sa setText(), setMaxLength()
261*/
262QLineEdit::QLineEdit(QWidget* parent)
263 : QWidget(*new QLineEditPrivate, parent,0)
264{
265 Q_D(QLineEdit);
266 d->init(QString());
267}
268
269/*!
270 Constructs a line edit containing the text \a contents.
271
272 The cursor position is set to the end of the line and the maximum
273 text length to 32767 characters.
274
275 The \a parent and argument is sent to the QWidget
276 constructor.
277
278 \sa text(), setMaxLength()
279*/
280QLineEdit::QLineEdit(const QString& contents, QWidget* parent)
281 : QWidget(*new QLineEditPrivate, parent, 0)
282{
283 Q_D(QLineEdit);
284 d->init(contents);
285}
286
287
288#ifdef QT3_SUPPORT
289/*!
290 Constructs a line edit with no text.
291
292 The maximum text length is set to 32767 characters.
293
294 The \a parent and \a name arguments are sent to the QWidget constructor.
295
296 \sa setText(), setMaxLength()
297*/
298QLineEdit::QLineEdit(QWidget* parent, const char* name)
299 : QWidget(*new QLineEditPrivate, parent,0)
300{
301 Q_D(QLineEdit);
302 setObjectName(QString::fromAscii(name));
303 d->init(QString());
304}
305
306/*!
307 Constructs a line edit containing the text \a contents.
308
309 The cursor position is set to the end of the line and the maximum
310 text length to 32767 characters.
311
312 The \a parent and \a name arguments are sent to the QWidget
313 constructor.
314
315 \sa text(), setMaxLength()
316*/
317
318QLineEdit::QLineEdit(const QString& contents, QWidget* parent, const char* name)
319 : QWidget(*new QLineEditPrivate, parent, 0)
320{
321 Q_D(QLineEdit);
322 setObjectName(QString::fromAscii(name));
323 d->init(contents);
324}
325
326/*!
327 Constructs a line edit with an input \a inputMask and the text \a
328 contents.
329
330 The cursor position is set to the end of the line and the maximum
331 text length is set to the length of the mask (the number of mask
332 characters and separators).
333
334 The \a parent and \a name arguments are sent to the QWidget
335 constructor.
336
337 \sa setMask() text()
338*/
339QLineEdit::QLineEdit(const QString& contents, const QString &inputMask, QWidget* parent, const char* name)
340 : QWidget(*new QLineEditPrivate, parent, 0)
341{
342 Q_D(QLineEdit);
343 setObjectName(QString::fromAscii(name));
344 d->init(contents);
345 d->control->setInputMask(inputMask);
346 d->control->moveCursor(d->control->nextMaskBlank(contents.length()));
347}
348#endif
349
350/*!
351 Destroys the line edit.
352*/
353
354QLineEdit::~QLineEdit()
355{
356}
357
358
359/*!
360 \property QLineEdit::text
361 \brief the line edit's text
362
363 Setting this property clears the selection, clears the undo/redo
364 history, moves the cursor to the end of the line and resets the
365 \l modified property to false. The text is not validated when
366 inserted with setText().
367
368 The text is truncated to maxLength() length.
369
370 By default, this property contains an empty string.
371
372 \sa insert(), clear()
373*/
374QString QLineEdit::text() const
375{
376 Q_D(const QLineEdit);
377 return d->control->text();
378}
379
380void QLineEdit::setText(const QString& text)
381{
382 Q_D(QLineEdit);
383 d->control->setText(text);
384}
385
386// ### Qt 4.7: remove this #if guard
387#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
388/*!
389 \since 4.7
390
391 \property QLineEdit::placeholderText
392 \brief the line edit's placeholder text
393
394 Setting this property makes the line edit display a grayed-out
395 placeholder text as long as the text() is empty and the widget doesn't
396 have focus.
397
398 By default, this property contains an empty string.
399
400 \sa text()
401*/
402QString QLineEdit::placeholderText() const
403{
404 Q_D(const QLineEdit);
405 return d->placeholderText;
406}
407
408void QLineEdit::setPlaceholderText(const QString& placeholderText)
409{
410 Q_D(QLineEdit);
411 if (d->placeholderText != placeholderText) {
412 d->placeholderText = placeholderText;
413 if (!hasFocus())
414 update();
415 }
416}
417#endif
418
419/*!
420 \property QLineEdit::displayText
421 \brief the displayed text
422
423 If \l echoMode is \l Normal this returns the same as text(); if
424 \l EchoMode is \l Password or \l PasswordEchoOnEdit it returns a string of asterisks
425 text().length() characters long, e.g. "******"; if \l EchoMode is
426 \l NoEcho returns an empty string, "".
427
428 By default, this property contains an empty string.
429
430 \sa setEchoMode() text() EchoMode
431*/
432
433QString QLineEdit::displayText() const
434{
435 Q_D(const QLineEdit);
436 return d->control->displayText();
437}
438
439
440/*!
441 \property QLineEdit::maxLength
442 \brief the maximum permitted length of the text
443
444 If the text is too long, it is truncated at the limit.
445
446 If truncation occurs any selected text will be unselected, the
447 cursor position is set to 0 and the first part of the string is
448 shown.
449
450 If the line edit has an input mask, the mask defines the maximum
451 string length.
452
453 By default, this property contains a value of 32767.
454
455 \sa inputMask
456*/
457
458int QLineEdit::maxLength() const
459{
460 Q_D(const QLineEdit);
461 return d->control->maxLength();
462}
463
464void QLineEdit::setMaxLength(int maxLength)
465{
466 Q_D(QLineEdit);
467 d->control->setMaxLength(maxLength);
468}
469
470/*!
471 \property QLineEdit::frame
472 \brief whether the line edit draws itself with a frame
473
474 If enabled (the default) the line edit draws itself inside a
475 frame, otherwise the line edit draws itself without any frame.
476*/
477bool QLineEdit::hasFrame() const
478{
479 Q_D(const QLineEdit);
480 return d->frame;
481}
482
483
484void QLineEdit::setFrame(bool enable)
485{
486 Q_D(QLineEdit);
487 d->frame = enable;
488 update();
489 updateGeometry();
490}
491
492
493/*!
494 \enum QLineEdit::EchoMode
495
496 This enum type describes how a line edit should display its
497 contents.
498
499 \value Normal Display characters as they are entered. This is the
500 default.
501 \value NoEcho Do not display anything. This may be appropriate
502 for passwords where even the length of the
503 password should be kept secret.
504 \value Password Display asterisks instead of the characters
505 actually entered.
506 \value PasswordEchoOnEdit Display characters as they are entered
507 while editing otherwise display asterisks.
508
509 \sa setEchoMode() echoMode()
510*/
511
512
513/*!
514 \property QLineEdit::echoMode
515 \brief the line edit's echo mode
516
517 The echo mode determines how the text entered in the line edit is
518 displayed (or echoed) to the user.
519
520 The most common setting is \l Normal, in which the text entered by the
521 user is displayed verbatim, but QLineEdit also supports modes that allow
522 the entered text to be suppressed or obscured: these include \l NoEcho,
523 \l Password and \l PasswordEchoOnEdit.
524
525 The widget's display and the ability to copy or drag the text is
526 affected by this setting.
527
528 By default, this property is set to \l Normal.
529
530 \sa EchoMode displayText()
531*/
532
533QLineEdit::EchoMode QLineEdit::echoMode() const
534{
535 Q_D(const QLineEdit);
536 return (EchoMode) d->control->echoMode();
537}
538
539void QLineEdit::setEchoMode(EchoMode mode)
540{
541 Q_D(QLineEdit);
542 if (mode == (EchoMode)d->control->echoMode())
543 return;
544 Qt::InputMethodHints imHints = inputMethodHints();
545 if (mode == Password) {
546 imHints |= Qt::ImhHiddenText;
547 } else {
548 imHints &= ~Qt::ImhHiddenText;
549 }
550 setInputMethodHints(imHints);
551 d->control->setEchoMode(mode);
552 update();
553#ifdef Q_WS_MAC
554 if (hasFocus())
555 qt_mac_secure_keyboard(mode == Password || mode == NoEcho);
556#endif
557}
558
559
560#ifndef QT_NO_VALIDATOR
561/*!
562 Returns a pointer to the current input validator, or 0 if no
563 validator has been set.
564
565 \sa setValidator()
566*/
567
568const QValidator * QLineEdit::validator() const
569{
570 Q_D(const QLineEdit);
571 return d->control->validator();
572}
573
574/*!
575 Sets this line edit to only accept input that the validator, \a v,
576 will accept. This allows you to place any arbitrary constraints on
577 the text which may be entered.
578
579 If \a v == 0, setValidator() removes the current input validator.
580 The initial setting is to have no input validator (i.e. any input
581 is accepted up to maxLength()).
582
583 \sa validator() QIntValidator QDoubleValidator QRegExpValidator
584*/
585
586void QLineEdit::setValidator(const QValidator *v)
587{
588 Q_D(QLineEdit);
589 d->control->setValidator(v);
590}
591#endif // QT_NO_VALIDATOR
592
593#ifndef QT_NO_COMPLETER
594/*!
595 \since 4.2
596
597 Sets this line edit to provide auto completions from the completer, \a c.
598 The completion mode is set using QCompleter::setCompletionMode().
599
600 To use a QCompleter with a QValidator or QLineEdit::inputMask, you need to
601 ensure that the model provided to QCompleter contains valid entries. You can
602 use the QSortFilterProxyModel to ensure that the QCompleter's model contains
603 only valid entries.
604
605 If \a c == 0, setCompleter() removes the current completer, effectively
606 disabling auto completion.
607
608 \sa QCompleter
609*/
610void QLineEdit::setCompleter(QCompleter *c)
611{
612 Q_D(QLineEdit);
613 if (c == d->control->completer())
614 return;
615 if (d->control->completer()) {
616 disconnect(d->control->completer(), 0, this, 0);
617 d->control->completer()->setWidget(0);
618 if (d->control->completer()->parent() == this)
619 delete d->control->completer();
620 }
621 d->control->setCompleter(c);
622 if (!c)
623 return;
624 if (c->widget() == 0)
625 c->setWidget(this);
626 if (hasFocus()) {
627 QObject::connect(d->control->completer(), SIGNAL(activated(QString)),
628 this, SLOT(setText(QString)));
629 QObject::connect(d->control->completer(), SIGNAL(highlighted(QString)),
630 this, SLOT(_q_completionHighlighted(QString)));
631 }
632}
633
634/*!
635 \since 4.2
636
637 Returns the current QCompleter that provides completions.
638*/
639QCompleter *QLineEdit::completer() const
640{
641 Q_D(const QLineEdit);
642 return d->control->completer();
643}
644
645#endif // QT_NO_COMPLETER
646
647/*!
648 Returns a recommended size for the widget.
649
650 The width returned, in pixels, is usually enough for about 15 to
651 20 characters.
652*/
653
654QSize QLineEdit::sizeHint() const
655{
656 Q_D(const QLineEdit);
657 ensurePolished();
658 QFontMetrics fm(font());
659 int h = qMax(fm.height(), 14) + 2*d->verticalMargin
660 + d->topTextMargin + d->bottomTextMargin
661 + d->topmargin + d->bottommargin;
662 int w = fm.width(QLatin1Char('x')) * 17 + 2*d->horizontalMargin
663 + d->leftTextMargin + d->rightTextMargin
664 + d->leftmargin + d->rightmargin; // "some"
665 QStyleOptionFrameV2 opt;
666 initStyleOption(&opt);
667 return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h).
668 expandedTo(QApplication::globalStrut()), this));
669}
670
671
672/*!
673 Returns a minimum size for the line edit.
674
675 The width returned is enough for at least one character.
676*/
677
678QSize QLineEdit::minimumSizeHint() const
679{
680 Q_D(const QLineEdit);
681 ensurePolished();
682 QFontMetrics fm = fontMetrics();
683 int h = fm.height() + qMax(2*d->verticalMargin, fm.leading())
684 + d->topmargin + d->bottommargin;
685 int w = fm.maxWidth() + d->leftmargin + d->rightmargin;
686 QStyleOptionFrameV2 opt;
687 initStyleOption(&opt);
688 return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h).
689 expandedTo(QApplication::globalStrut()), this));
690}
691
692
693/*!
694 \property QLineEdit::cursorPosition
695 \brief the current cursor position for this line edit
696
697 Setting the cursor position causes a repaint when appropriate.
698
699 By default, this property contains a value of 0.
700*/
701
702int QLineEdit::cursorPosition() const
703{
704 Q_D(const QLineEdit);
705 return d->control->cursorPosition();
706}
707
708void QLineEdit::setCursorPosition(int pos)
709{
710 Q_D(QLineEdit);
711 d->control->setCursorPosition(pos);
712}
713
714/*!
715 Returns the cursor position under the point \a pos.
716*/
717// ### What should this do if the point is outside of contentsRect? Currently returns 0.
718int QLineEdit::cursorPositionAt(const QPoint &pos)
719{
720 Q_D(QLineEdit);
721 return d->xToPos(pos.x());
722}
723
724
725#ifdef QT3_SUPPORT
726/*! \obsolete
727
728 Use setText(), setCursorPosition() and setSelection() instead.
729*/
730bool QLineEdit::validateAndSet(const QString &newText, int newPos,
731 int newMarkAnchor, int newMarkDrag)
732{
733 // The suggested functions above in the docs don't seem to validate,
734 // below code tries to mimic previous behaviour.
735 QString oldText = text();
736 setText(newText);
737 if(!hasAcceptableInput()){
738 setText(oldText);
739 return false;
740 }
741 int selstart = qMin(newMarkAnchor, newMarkDrag);
742 int sellength = qAbs(newMarkAnchor - newMarkDrag);
743 if (selstart == newPos) {
744 selstart = qMax(newMarkAnchor, newMarkDrag);
745 sellength = -sellength;
746 }
747 //setSelection also set the position
748 setSelection(selstart, sellength);
749 return true;
750}
751#endif //QT3_SUPPORT
752
753/*!
754 \property QLineEdit::alignment
755 \brief the alignment of the line edit
756
757 Both horizontal and vertical alignment is allowed here, Qt::AlignJustify
758 will map to Qt::AlignLeft.
759
760 By default, this property contains a combination of Qt::AlignLeft and Qt::AlignVCenter.
761
762 \sa Qt::Alignment
763*/
764
765Qt::Alignment QLineEdit::alignment() const
766{
767 Q_D(const QLineEdit);
768 return QFlag(d->alignment);
769}
770
771void QLineEdit::setAlignment(Qt::Alignment alignment)
772{
773 Q_D(QLineEdit);
774 d->alignment = alignment;
775 update();
776}
777
778
779/*!
780 Moves the cursor forward \a steps characters. If \a mark is true
781 each character moved over is added to the selection; if \a mark is
782 false the selection is cleared.
783
784 \sa cursorBackward()
785*/
786
787void QLineEdit::cursorForward(bool mark, int steps)
788{
789 Q_D(QLineEdit);
790 d->control->cursorForward(mark, steps);
791}
792
793
794/*!
795 Moves the cursor back \a steps characters. If \a mark is true each
796 character moved over is added to the selection; if \a mark is
797 false the selection is cleared.
798
799 \sa cursorForward()
800*/
801void QLineEdit::cursorBackward(bool mark, int steps)
802{
803 cursorForward(mark, -steps);
804}
805
806/*!
807 Moves the cursor one word forward. If \a mark is true, the word is
808 also selected.
809
810 \sa cursorWordBackward()
811*/
812void QLineEdit::cursorWordForward(bool mark)
813{
814 Q_D(QLineEdit);
815 d->control->cursorWordForward(mark);
816}
817
818/*!
819 Moves the cursor one word backward. If \a mark is true, the word
820 is also selected.
821
822 \sa cursorWordForward()
823*/
824
825void QLineEdit::cursorWordBackward(bool mark)
826{
827 Q_D(QLineEdit);
828 d->control->cursorWordBackward(mark);
829}
830
831
832/*!
833 If no text is selected, deletes the character to the left of the
834 text cursor and moves the cursor one position to the left. If any
835 text is selected, the cursor is moved to the beginning of the
836 selected text and the selected text is deleted.
837
838 \sa del()
839*/
840void QLineEdit::backspace()
841{
842 Q_D(QLineEdit);
843 d->control->backspace();
844}
845
846/*!
847 If no text is selected, deletes the character to the right of the
848 text cursor. If any text is selected, the cursor is moved to the
849 beginning of the selected text and the selected text is deleted.
850
851 \sa backspace()
852*/
853
854void QLineEdit::del()
855{
856 Q_D(QLineEdit);
857 d->control->del();
858}
859
860/*!
861 Moves the text cursor to the beginning of the line unless it is
862 already there. If \a mark is true, text is selected towards the
863 first position; otherwise, any selected text is unselected if the
864 cursor is moved.
865
866 \sa end()
867*/
868
869void QLineEdit::home(bool mark)
870{
871 Q_D(QLineEdit);
872 d->control->home(mark);
873}
874
875/*!
876 Moves the text cursor to the end of the line unless it is already
877 there. If \a mark is true, text is selected towards the last
878 position; otherwise, any selected text is unselected if the cursor
879 is moved.
880
881 \sa home()
882*/
883
884void QLineEdit::end(bool mark)
885{
886 Q_D(QLineEdit);
887 d->control->end(mark);
888}
889
890
891/*!
892 \property QLineEdit::modified
893 \brief whether the line edit's contents has been modified by the user
894
895 The modified flag is never read by QLineEdit; it has a default value
896 of false and is changed to true whenever the user changes the line
897 edit's contents.
898
899 This is useful for things that need to provide a default value but
900 do not start out knowing what the default should be (perhaps it
901 depends on other fields on the form). Start the line edit without
902 the best default, and when the default is known, if modified()
903 returns false (the user hasn't entered any text), insert the
904 default value.
905
906 Calling setText() resets the modified flag to false.
907*/
908
909bool QLineEdit::isModified() const
910{
911 Q_D(const QLineEdit);
912 return d->control->isModified();
913}
914
915void QLineEdit::setModified(bool modified)
916{
917 Q_D(QLineEdit);
918 d->control->setModified(modified);
919}
920
921
922/*!\fn QLineEdit::clearModified()
923
924Use setModified(false) instead.
925
926 \sa isModified()
927*/
928
929
930/*!
931 \property QLineEdit::hasSelectedText
932 \brief whether there is any text selected
933
934 hasSelectedText() returns true if some or all of the text has been
935 selected by the user; otherwise returns false.
936
937 By default, this property is false.
938
939 \sa selectedText()
940*/
941
942
943bool QLineEdit::hasSelectedText() const
944{
945 Q_D(const QLineEdit);
946 return d->control->hasSelectedText();
947}
948
949/*!
950 \property QLineEdit::selectedText
951 \brief the selected text
952
953 If there is no selected text this property's value is
954 an empty string.
955
956 By default, this property contains an empty string.
957
958 \sa hasSelectedText()
959*/
960
961QString QLineEdit::selectedText() const
962{
963 Q_D(const QLineEdit);
964 return d->control->selectedText();
965}
966
967/*!
968 selectionStart() returns the index of the first selected character in the
969 line edit or -1 if no text is selected.
970
971 \sa selectedText()
972*/
973
974int QLineEdit::selectionStart() const
975{
976 Q_D(const QLineEdit);
977 return d->control->selectionStart();
978}
979
980
981#ifdef QT3_SUPPORT
982
983/*!
984 \fn void QLineEdit::lostFocus()
985
986 This signal is emitted when the line edit has lost focus.
987
988 Use editingFinished() instead
989 \sa editingFinished(), returnPressed()
990*/
991
992/*!
993 Use isModified() instead.
994*/
995bool QLineEdit::edited() const { return isModified(); }
996/*!
997 Use setModified() or setText().
998*/
999void QLineEdit::setEdited(bool on) { setModified(on); }
1000
1001/*!
1002 There exists no equivalent functionality in Qt 4.
1003*/
1004int QLineEdit::characterAt(int xpos, QChar *chr) const
1005{
1006 Q_D(const QLineEdit);
1007 int pos = d->xToPos(xpos + contentsRect().x() - d->hscroll + d->horizontalMargin);
1008 QString txt = d->control->text();
1009 if (chr && pos < (int) txt.length())
1010 *chr = txt.at(pos);
1011 return pos;
1012
1013}
1014
1015/*!
1016 Use selectedText() and selectionStart() instead.
1017*/
1018bool QLineEdit::getSelection(int *start, int *end)
1019{
1020 Q_D(QLineEdit);
1021 if (d->control->hasSelectedText() && start && end) {
1022 *start = selectionStart();
1023 *end = *start + selectedText().length();
1024 return true;
1025 }
1026 return false;
1027}
1028#endif
1029
1030
1031/*!
1032 Selects text from position \a start and for \a length characters.
1033 Negative lengths are allowed.
1034
1035 \sa deselect() selectAll() selectedText()
1036*/
1037
1038void QLineEdit::setSelection(int start, int length)
1039{
1040 Q_D(QLineEdit);
1041 if (start < 0 || start > (int)d->control->text().length()) {
1042 qWarning("QLineEdit::setSelection: Invalid start position (%d)", start);
1043 return;
1044 }
1045
1046 d->control->setSelection(start, length);
1047
1048 if (d->control->hasSelectedText()){
1049 QStyleOptionFrameV2 opt;
1050 initStyleOption(&opt);
1051 if (!style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this))
1052 d->setCursorVisible(false);
1053 }
1054}
1055
1056
1057/*!
1058 \property QLineEdit::undoAvailable
1059 \brief whether undo is available
1060
1061 Undo becomes available once the user has modified the text in the line edit.
1062
1063 By default, this property is false.
1064*/
1065
1066bool QLineEdit::isUndoAvailable() const
1067{
1068 Q_D(const QLineEdit);
1069 return d->control->isUndoAvailable();
1070}
1071
1072/*!
1073 \property QLineEdit::redoAvailable
1074 \brief whether redo is available
1075
1076 Redo becomes available once the user has performed one or more undo operations
1077 on text in the line edit.
1078
1079 By default, this property is false.
1080*/
1081
1082bool QLineEdit::isRedoAvailable() const
1083{
1084 Q_D(const QLineEdit);
1085 return d->control->isRedoAvailable();
1086}
1087
1088/*!
1089 \property QLineEdit::dragEnabled
1090 \brief whether the lineedit starts a drag if the user presses and
1091 moves the mouse on some selected text
1092
1093 Dragging is disabled by default.
1094*/
1095
1096bool QLineEdit::dragEnabled() const
1097{
1098 Q_D(const QLineEdit);
1099 return d->dragEnabled;
1100}
1101
1102void QLineEdit::setDragEnabled(bool b)
1103{
1104 Q_D(QLineEdit);
1105 d->dragEnabled = b;
1106}
1107
1108
1109/*!
1110 \property QLineEdit::acceptableInput
1111 \brief whether the input satisfies the inputMask and the
1112 validator.
1113
1114 By default, this property is true.
1115
1116 \sa setInputMask(), setValidator()
1117*/
1118bool QLineEdit::hasAcceptableInput() const
1119{
1120 Q_D(const QLineEdit);
1121 return d->control->hasAcceptableInput();
1122}
1123
1124/*!
1125 Sets the margins around the text inside the frame to have the
1126 sizes \a left, \a top, \a right, and \a bottom.
1127 \since 4.5
1128
1129 See also getTextMargins().
1130*/
1131void QLineEdit::setTextMargins(int left, int top, int right, int bottom)
1132{
1133 Q_D(QLineEdit);
1134 d->leftTextMargin = left;
1135 d->topTextMargin = top;
1136 d->rightTextMargin = right;
1137 d->bottomTextMargin = bottom;
1138 updateGeometry();
1139 update();
1140}
1141
1142/*!
1143 \since 4.6
1144 Sets the \a margins around the text inside the frame.
1145
1146 See also textMargins().
1147*/
1148void QLineEdit::setTextMargins(const QMargins &margins)
1149{
1150 setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom());
1151}
1152
1153/*!
1154 Returns the widget's text margins for \a left, \a top, \a right, and \a bottom.
1155 \since 4.5
1156
1157 \sa setTextMargins()
1158*/
1159void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) const
1160{
1161 Q_D(const QLineEdit);
1162 if (left)
1163 *left = d->leftTextMargin;
1164 if (top)
1165 *top = d->topTextMargin;
1166 if (right)
1167 *right = d->rightTextMargin;
1168 if (bottom)
1169 *bottom = d->bottomTextMargin;
1170}
1171
1172/*!
1173 \since 4.6
1174 Returns the widget's text margins.
1175
1176 \sa setTextMargins()
1177*/
1178QMargins QLineEdit::textMargins() const
1179{
1180 Q_D(const QLineEdit);
1181 return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin);
1182}
1183
1184/*!
1185 \property QLineEdit::inputMask
1186 \brief The validation input mask
1187
1188 If no mask is set, inputMask() returns an empty string.
1189
1190 Sets the QLineEdit's validation mask. Validators can be used
1191 instead of, or in conjunction with masks; see setValidator().
1192
1193 Unset the mask and return to normal QLineEdit operation by passing
1194 an empty string ("") or just calling setInputMask() with no
1195 arguments.
1196
1197 The table below shows the characters that can be used in an input mask.
1198 A space character, the default character for a blank, is needed for cases
1199 where a character is \e{permitted but not required}.
1200
1201 \table
1202 \header \i Character \i Meaning
1203 \row \i \c A \i ASCII alphabetic character required. A-Z, a-z.
1204 \row \i \c a \i ASCII alphabetic character permitted but not required.
1205 \row \i \c N \i ASCII alphanumeric character required. A-Z, a-z, 0-9.
1206 \row \i \c n \i ASCII alphanumeric character permitted but not required.
1207 \row \i \c X \i Any character required.
1208 \row \i \c x \i Any character permitted but not required.
1209 \row \i \c 9 \i ASCII digit required. 0-9.
1210 \row \i \c 0 \i ASCII digit permitted but not required.
1211 \row \i \c D \i ASCII digit required. 1-9.
1212 \row \i \c d \i ASCII digit permitted but not required (1-9).
1213 \row \i \c # \i ASCII digit or plus/minus sign permitted but not required.
1214 \row \i \c H \i Hexadecimal character required. A-F, a-f, 0-9.
1215 \row \i \c h \i Hexadecimal character permitted but not required.
1216 \row \i \c B \i Binary character required. 0-1.
1217 \row \i \c b \i Binary character permitted but not required.
1218 \row \i \c > \i All following alphabetic characters are uppercased.
1219 \row \i \c < \i All following alphabetic characters are lowercased.
1220 \row \i \c ! \i Switch off case conversion.
1221 \row \i \tt{\\} \i Use \tt{\\} to escape the special
1222 characters listed above to use them as
1223 separators.
1224 \endtable
1225
1226 The mask consists of a string of mask characters and separators,
1227 optionally followed by a semicolon and the character used for
1228 blanks. The blank characters are always removed from the text
1229 after editing.
1230
1231 Examples:
1232 \table
1233 \header \i Mask \i Notes
1234 \row \i \c 000.000.000.000;_ \i IP address; blanks are \c{_}.
1235 \row \i \c HH:HH:HH:HH:HH:HH;_ \i MAC address
1236 \row \i \c 0000-00-00 \i ISO Date; blanks are \c space
1237 \row \i \c >AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;# \i License number;
1238 blanks are \c - and all (alphabetic) characters are converted to
1239 uppercase.
1240 \endtable
1241
1242 To get range control (e.g., for an IP address) use masks together
1243 with \link setValidator() validators\endlink.
1244
1245 \sa maxLength
1246*/
1247QString QLineEdit::inputMask() const
1248{
1249 Q_D(const QLineEdit);
1250 return d->control->inputMask();
1251}
1252
1253void QLineEdit::setInputMask(const QString &inputMask)
1254{
1255 Q_D(QLineEdit);
1256 d->control->setInputMask(inputMask);
1257}
1258
1259/*!
1260 Selects all the text (i.e. highlights it) and moves the cursor to
1261 the end. This is useful when a default value has been inserted
1262 because if the user types before clicking on the widget, the
1263 selected text will be deleted.
1264
1265 \sa setSelection() deselect()
1266*/
1267
1268void QLineEdit::selectAll()
1269{
1270 Q_D(QLineEdit);
1271 d->control->selectAll();
1272}
1273
1274/*!
1275 Deselects any selected text.
1276
1277 \sa setSelection() selectAll()
1278*/
1279
1280void QLineEdit::deselect()
1281{
1282 Q_D(QLineEdit);
1283 d->control->deselect();
1284}
1285
1286
1287/*!
1288 Deletes any selected text, inserts \a newText, and validates the
1289 result. If it is valid, it sets it as the new contents of the line
1290 edit.
1291
1292 \sa setText(), clear()
1293*/
1294void QLineEdit::insert(const QString &newText)
1295{
1296// q->resetInputContext(); //#### FIX ME IN QT
1297 Q_D(QLineEdit);
1298 d->control->insert(newText);
1299}
1300
1301/*!
1302 Clears the contents of the line edit.
1303
1304 \sa setText(), insert()
1305*/
1306void QLineEdit::clear()
1307{
1308 Q_D(QLineEdit);
1309 resetInputContext();
1310 d->control->clear();
1311}
1312
1313/*!
1314 Undoes the last operation if undo is \link
1315 QLineEdit::undoAvailable available\endlink. Deselects any current
1316 selection, and updates the selection start to the current cursor
1317 position.
1318*/
1319void QLineEdit::undo()
1320{
1321 Q_D(QLineEdit);
1322 resetInputContext();
1323 d->control->undo();
1324}
1325
1326/*!
1327 Redoes the last operation if redo is \link
1328 QLineEdit::redoAvailable available\endlink.
1329*/
1330void QLineEdit::redo()
1331{
1332 Q_D(QLineEdit);
1333 resetInputContext();
1334 d->control->redo();
1335}
1336
1337
1338/*!
1339 \property QLineEdit::readOnly
1340 \brief whether the line edit is read only.
1341
1342 In read-only mode, the user can still copy the text to the
1343 clipboard, or drag and drop the text (if echoMode() is \l Normal),
1344 but cannot edit it.
1345
1346 QLineEdit does not show a cursor in read-only mode.
1347
1348 By default, this property is false.
1349
1350 \sa setEnabled()
1351*/
1352
1353bool QLineEdit::isReadOnly() const
1354{
1355 Q_D(const QLineEdit);
1356 return d->control->isReadOnly();
1357}
1358
1359void QLineEdit::setReadOnly(bool enable)
1360{
1361 Q_D(QLineEdit);
1362 if (d->control->isReadOnly() != enable) {
1363 d->control->setReadOnly(enable);
1364 setAttribute(Qt::WA_MacShowFocusRect, !enable);
1365 setAttribute(Qt::WA_InputMethodEnabled, d->shouldEnableInputMethod());
1366#ifndef QT_NO_CURSOR
1367 setCursor(enable ? Qt::ArrowCursor : Qt::IBeamCursor);
1368#endif
1369 update();
1370 }
1371}
1372
1373
1374#ifndef QT_NO_CLIPBOARD
1375/*!
1376 Copies the selected text to the clipboard and deletes it, if there
1377 is any, and if echoMode() is \l Normal.
1378
1379 If the current validator disallows deleting the selected text,
1380 cut() will copy without deleting.
1381
1382 \sa copy() paste() setValidator()
1383*/
1384
1385void QLineEdit::cut()
1386{
1387 if (hasSelectedText()) {
1388 copy();
1389 del();
1390 }
1391}
1392
1393
1394/*!
1395 Copies the selected text to the clipboard, if there is any, and if
1396 echoMode() is \l Normal.
1397
1398 \sa cut() paste()
1399*/
1400
1401void QLineEdit::copy() const
1402{
1403 Q_D(const QLineEdit);
1404 d->control->copy();
1405}
1406
1407/*!
1408 Inserts the clipboard's text at the cursor position, deleting any
1409 selected text, providing the line edit is not \link
1410 QLineEdit::readOnly read-only\endlink.
1411
1412 If the end result would not be acceptable to the current
1413 \link setValidator() validator\endlink, nothing happens.
1414
1415 \sa copy() cut()
1416*/
1417
1418void QLineEdit::paste()
1419{
1420 Q_D(QLineEdit);
1421 d->control->paste();
1422}
1423
1424#endif // !QT_NO_CLIPBOARD
1425
1426/*! \reimp
1427*/
1428bool QLineEdit::event(QEvent * e)
1429{
1430 Q_D(QLineEdit);
1431 if (e->type() == QEvent::Timer) {
1432 // should be timerEvent, is here for binary compatibility
1433 int timerId = ((QTimerEvent*)e)->timerId();
1434 if (false) {
1435#ifndef QT_NO_DRAGANDDROP
1436 } else if (timerId == d->dndTimer.timerId()) {
1437 d->drag();
1438#endif
1439 }
1440 else if (timerId == d->tripleClickTimer.timerId())
1441 d->tripleClickTimer.stop();
1442 } else if (e->type() == QEvent::ContextMenu) {
1443#ifndef QT_NO_IM
1444 if (d->control->composeMode())
1445 return true;
1446#endif
1447 //d->separate();
1448 } else if (e->type() == QEvent::WindowActivate) {
1449 QTimer::singleShot(0, this, SLOT(_q_handleWindowActivate()));
1450 }else if(e->type() == QEvent::ShortcutOverride){
1451 d->control->processEvent(e);
1452 } else if (e->type() == QEvent::KeyRelease) {
1453 d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
1454 } else if (e->type() == QEvent::Show) {
1455 //In order to get the cursor blinking if QComboBox::setEditable is called when the combobox has focus
1456 if (hasFocus()) {
1457 d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
1458 QStyleOptionFrameV2 opt;
1459 initStyleOption(&opt);
1460 if ((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
1461 || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this))
1462 d->setCursorVisible(true);
1463 }
1464 }
1465
1466#ifdef QT_KEYPAD_NAVIGATION
1467 if (QApplication::keypadNavigationEnabled()) {
1468 if (e->type() == QEvent::EnterEditFocus) {
1469 end(false);
1470 d->setCursorVisible(true);
1471 d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
1472 } else if (e->type() == QEvent::LeaveEditFocus) {
1473 d->setCursorVisible(false);
1474 d->control->setCursorBlinkPeriod(0);
1475 if (d->control->hasAcceptableInput() || d->control->fixup())
1476 emit editingFinished();
1477 }
1478 }
1479#endif
1480 return QWidget::event(e);
1481}
1482
1483/*! \reimp
1484*/
1485void QLineEdit::mousePressEvent(QMouseEvent* e)
1486{
1487 Q_D(QLineEdit);
1488 if (d->sendMouseEventToInputContext(e))
1489 return;
1490 if (e->button() == Qt::RightButton)
1491 return;
1492#ifdef QT_KEYPAD_NAVIGATION
1493 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
1494 setEditFocus(true);
1495 // Get the completion list to pop up.
1496 if (d->control->completer())
1497 d->control->completer()->complete();
1498 }
1499#endif
1500 if (d->tripleClickTimer.isActive() && (e->pos() - d->tripleClick).manhattanLength() <
1501 QApplication::startDragDistance()) {
1502 selectAll();
1503 return;
1504 }
1505 bool mark = e->modifiers() & Qt::ShiftModifier;
1506 int cursor = d->xToPos(e->pos().x());
1507#ifndef QT_NO_DRAGANDDROP
1508 if (!mark && d->dragEnabled && d->control->echoMode() == Normal &&
1509 e->button() == Qt::LeftButton && d->control->inSelection(e->pos().x())) {
1510 d->dndPos = e->pos();
1511 if (!d->dndTimer.isActive())
1512 d->dndTimer.start(QApplication::startDragTime(), this);
1513 } else
1514#endif
1515 {
1516 d->control->moveCursor(cursor, mark);
1517 }
1518}
1519
1520/*! \reimp
1521*/
1522void QLineEdit::mouseMoveEvent(QMouseEvent * e)
1523{
1524 Q_D(QLineEdit);
1525 if (d->sendMouseEventToInputContext(e))
1526 return;
1527
1528 if (e->buttons() & Qt::LeftButton) {
1529#ifndef QT_NO_DRAGANDDROP
1530 if (d->dndTimer.isActive()) {
1531 if ((d->dndPos - e->pos()).manhattanLength() > QApplication::startDragDistance())
1532 d->drag();
1533 } else
1534#endif
1535 {
1536 d->control->moveCursor(d->xToPos(e->pos().x()), true);
1537 }
1538 }
1539}
1540
1541/*! \reimp
1542*/
1543void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
1544{
1545 Q_D(QLineEdit);
1546 if (d->sendMouseEventToInputContext(e))
1547 return;
1548#ifndef QT_NO_DRAGANDDROP
1549 if (e->button() == Qt::LeftButton) {
1550 if (d->dndTimer.isActive()) {
1551 d->dndTimer.stop();
1552 deselect();
1553 return;
1554 }
1555 }
1556#endif
1557#ifndef QT_NO_CLIPBOARD
1558 if (QApplication::clipboard()->supportsSelection()) {
1559 if (e->button() == Qt::LeftButton) {
1560 d->control->copy(QClipboard::Selection);
1561 } else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) {
1562 deselect();
1563 insert(QApplication::clipboard()->text(QClipboard::Selection));
1564 }
1565 }
1566#endif
1567
1568 if (!isReadOnly() && rect().contains(e->pos()))
1569 d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
1570 d->clickCausedFocus = 0;
1571}
1572
1573/*! \reimp
1574*/
1575void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
1576{
1577 Q_D(QLineEdit);
1578 if (d->sendMouseEventToInputContext(e))
1579 return;
1580 if (e->button() == Qt::LeftButton) {
1581 d->control->selectWordAtPos(d->xToPos(e->pos().x()));
1582 d->tripleClickTimer.start(QApplication::doubleClickInterval(), this);
1583 d->tripleClick = e->pos();
1584 }
1585}
1586
1587/*!
1588 \fn void QLineEdit::returnPressed()
1589
1590 This signal is emitted when the Return or Enter key is pressed.
1591 Note that if there is a validator() or inputMask() set on the line
1592 edit, the returnPressed() signal will only be emitted if the input
1593 follows the inputMask() and the validator() returns
1594 QValidator::Acceptable.
1595*/
1596
1597/*!
1598 \fn void QLineEdit::editingFinished()
1599
1600 This signal is emitted when the Return or Enter key is pressed or
1601 the line edit loses focus. Note that if there is a validator() or
1602 inputMask() set on the line edit and enter/return is pressed, the
1603 editingFinished() signal will only be emitted if the input follows
1604 the inputMask() and the validator() returns QValidator::Acceptable.
1605*/
1606
1607/*!
1608 Converts the given key press \a event into a line edit action.
1609
1610 If Return or Enter is pressed and the current text is valid (or
1611 can be \link QValidator::fixup() made valid\endlink by the
1612 validator), the signal returnPressed() is emitted.
1613
1614 The default key bindings are listed in the class's detailed
1615 description.
1616*/
1617
1618void QLineEdit::keyPressEvent(QKeyEvent *event)
1619{
1620 Q_D(QLineEdit);
1621 #ifdef QT_KEYPAD_NAVIGATION
1622 bool select = false;
1623 switch (event->key()) {
1624 case Qt::Key_Select:
1625 if (QApplication::keypadNavigationEnabled()) {
1626 if (hasEditFocus()) {
1627 setEditFocus(false);
1628 if (d->control->completer() && d->control->completer()->popup()->isVisible())
1629 d->control->completer()->popup()->hide();
1630 select = true;
1631 }
1632 }
1633 break;
1634 case Qt::Key_Back:
1635 case Qt::Key_No:
1636 if (!QApplication::keypadNavigationEnabled() || !hasEditFocus()) {
1637 event->ignore();
1638 return;
1639 }
1640 break;
1641 default:
1642 if (QApplication::keypadNavigationEnabled()) {
1643 if (!hasEditFocus() && !(event->modifiers() & Qt::ControlModifier)) {
1644 if (!event->text().isEmpty() && event->text().at(0).isPrint()
1645 && !isReadOnly())
1646 {
1647 setEditFocus(true);
1648#ifndef Q_OS_SYMBIAN
1649 clear();
1650#endif
1651 } else {
1652 event->ignore();
1653 return;
1654 }
1655 }
1656 }
1657 }
1658
1659
1660
1661 if (QApplication::keypadNavigationEnabled() && !select && !hasEditFocus()) {
1662 setEditFocus(true);
1663 if (event->key() == Qt::Key_Select)
1664 return; // Just start. No action.
1665 }
1666#endif
1667 d->control->processKeyEvent(event);
1668 if (event->isAccepted())
1669 d->control->setCursorBlinkPeriod(0);
1670}
1671
1672/*!
1673 \since 4.4
1674
1675 Returns a rectangle that includes the lineedit cursor.
1676*/
1677QRect QLineEdit::cursorRect() const
1678{
1679 Q_D(const QLineEdit);
1680 return d->cursorRect();
1681}
1682
1683/*! \reimp
1684 */
1685void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
1686{
1687 Q_D(QLineEdit);
1688 if (d->control->isReadOnly()) {
1689 e->ignore();
1690 return;
1691 }
1692
1693 if (echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing()) {
1694 // Clear the edit and reset to normal echo mode while entering input
1695 // method data; the echo mode switches back when the edit loses focus.
1696 // ### changes a public property, resets current content.
1697 d->updatePasswordEchoEditing(true);
1698 clear();
1699 }
1700
1701#ifdef QT_KEYPAD_NAVIGATION
1702 // Focus in if currently in navigation focus on the widget
1703 // Only focus in on preedits, to allow input methods to
1704 // commit text as they focus out without interfering with focus
1705 if (QApplication::keypadNavigationEnabled()
1706 && hasFocus() && !hasEditFocus()
1707 && !e->preeditString().isEmpty()) {
1708 setEditFocus(true);
1709#ifndef Q_OS_SYMBIAN
1710 selectAll(); // so text is replaced rather than appended to
1711#endif
1712 }
1713#endif
1714
1715 d->control->processInputMethodEvent(e);
1716
1717#ifndef QT_NO_COMPLETER
1718 if (!e->commitString().isEmpty())
1719 d->control->complete(Qt::Key_unknown);
1720#endif
1721}
1722
1723/*!\reimp
1724*/
1725QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
1726{
1727 Q_D(const QLineEdit);
1728 switch(property) {
1729 case Qt::ImMicroFocus:
1730 return d->cursorRect();
1731 case Qt::ImFont:
1732 return font();
1733 case Qt::ImCursorPosition:
1734 return QVariant(d->control->cursor());
1735 case Qt::ImSurroundingText:
1736 return QVariant(text());
1737 case Qt::ImCurrentSelection:
1738 return QVariant(selectedText());
1739 case Qt::ImMaximumTextLength:
1740 return QVariant(maxLength());
1741 case Qt::ImAnchorPosition:
1742 if (d->control->selectionStart() == d->control->selectionEnd())
1743 return QVariant(d->control->cursor());
1744 else if (d->control->selectionStart() == d->control->cursor())
1745 return QVariant(d->control->selectionEnd());
1746 else
1747 return QVariant(d->control->selectionStart());
1748 default:
1749 return QVariant();
1750 }
1751}
1752
1753/*!\reimp
1754*/
1755
1756void QLineEdit::focusInEvent(QFocusEvent *e)
1757{
1758 Q_D(QLineEdit);
1759 if (e->reason() == Qt::TabFocusReason ||
1760 e->reason() == Qt::BacktabFocusReason ||
1761 e->reason() == Qt::ShortcutFocusReason) {
1762 if (!d->control->inputMask().isEmpty())
1763 d->control->moveCursor(d->control->nextMaskBlank(0));
1764 else if (!d->control->hasSelectedText())
1765 selectAll();
1766 } else if (e->reason() == Qt::MouseFocusReason) {
1767 d->clickCausedFocus = 1;
1768 }
1769#ifdef QT_KEYPAD_NAVIGATION
1770 if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && ( e->reason() == Qt::PopupFocusReason
1771#ifdef Q_OS_SYMBIAN
1772 || e->reason() == Qt::ActiveWindowFocusReason
1773#endif
1774 ))) {
1775#endif
1776 d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
1777 QStyleOptionFrameV2 opt;
1778 initStyleOption(&opt);
1779 if((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
1780 || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this))
1781 d->setCursorVisible(true);
1782#ifdef Q_WS_MAC
1783 if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho)
1784 qt_mac_secure_keyboard(true);
1785#endif
1786#ifdef QT_KEYPAD_NAVIGATION
1787 d->control->setCancelText(d->control->text());
1788 }
1789#endif
1790#ifndef QT_NO_COMPLETER
1791 if (d->control->completer()) {
1792 d->control->completer()->setWidget(this);
1793 QObject::connect(d->control->completer(), SIGNAL(activated(QString)),
1794 this, SLOT(setText(QString)));
1795 QObject::connect(d->control->completer(), SIGNAL(highlighted(QString)),
1796 this, SLOT(_q_completionHighlighted(QString)));
1797 }
1798#endif
1799 update();
1800}
1801
1802/*!\reimp
1803*/
1804
1805void QLineEdit::focusOutEvent(QFocusEvent *e)
1806{
1807 Q_D(QLineEdit);
1808 if (d->control->passwordEchoEditing()) {
1809 // Reset the echomode back to PasswordEchoOnEdit when the widget loses
1810 // focus.
1811 d->updatePasswordEchoEditing(false);
1812 }
1813
1814 Qt::FocusReason reason = e->reason();
1815 if (reason != Qt::ActiveWindowFocusReason &&
1816 reason != Qt::PopupFocusReason)
1817 deselect();
1818
1819 d->setCursorVisible(false);
1820 d->control->setCursorBlinkPeriod(0);
1821#ifdef QT_KEYPAD_NAVIGATION
1822 // editingFinished() is already emitted on LeaveEditFocus
1823 if (!QApplication::keypadNavigationEnabled())
1824#endif
1825 if (reason != Qt::PopupFocusReason
1826 || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() == this)) {
1827 if (hasAcceptableInput() || d->control->fixup())
1828 emit editingFinished();
1829#ifdef QT3_SUPPORT
1830 emit lostFocus();
1831#endif
1832 }
1833#ifdef Q_WS_MAC
1834 if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho)
1835 qt_mac_secure_keyboard(false);
1836#endif
1837#ifdef QT_KEYPAD_NAVIGATION
1838 d->control->setCancelText(QString());
1839#endif
1840#ifndef QT_NO_COMPLETER
1841 if (d->control->completer()) {
1842 QObject::disconnect(d->control->completer(), 0, this, 0);
1843 }
1844#endif
1845 update();
1846}
1847
1848/*!\reimp
1849*/
1850void QLineEdit::paintEvent(QPaintEvent *)
1851{
1852 Q_D(QLineEdit);
1853 QPainter p(this);
1854
1855 QRect r = rect();
1856 QPalette pal = palette();
1857
1858 QStyleOptionFrameV2 panel;
1859 initStyleOption(&panel);
1860 style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this);
1861 r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
1862 r.setX(r.x() + d->leftTextMargin);
1863 r.setY(r.y() + d->topTextMargin);
1864 r.setRight(r.right() - d->rightTextMargin);
1865 r.setBottom(r.bottom() - d->bottomTextMargin);
1866 p.setClipRect(r);
1867
1868 QFontMetrics fm = fontMetrics();
1869 Qt::Alignment va = QStyle::visualAlignment(layoutDirection(), QFlag(d->alignment));
1870 switch (va & Qt::AlignVertical_Mask) {
1871 case Qt::AlignBottom:
1872 d->vscroll = r.y() + r.height() - fm.height() - d->verticalMargin;
1873 break;
1874 case Qt::AlignTop:
1875 d->vscroll = r.y() + d->verticalMargin;
1876 break;
1877 default:
1878 //center
1879 d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2;
1880 break;
1881 }
1882 QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height());
1883
1884 if (d->control->text().isEmpty()) {
1885 if (!hasFocus() && !d->placeholderText.isEmpty()) {
1886 QColor col = pal.text().color();
1887 col.setAlpha(128);
1888 QPen oldpen = p.pen();
1889 p.setPen(col);
1890 p.drawText(lineRect, va, d->placeholderText);
1891 p.setPen(oldpen);
1892 return;
1893 }
1894 }
1895
1896 int cix = qRound(d->control->cursorToX());
1897
1898 // horizontal scrolling. d->hscroll is the left indent from the beginning
1899 // of the text line to the left edge of lineRect. we update this value
1900 // depending on the delta from the last paint event; in effect this means
1901 // the below code handles all scrolling based on the textline (widthUsed,
1902 // minLB, minRB), the line edit rect (lineRect) and the cursor position
1903 // (cix).
1904 int minLB = qMax(0, -fm.minLeftBearing());
1905 int minRB = qMax(0, -fm.minRightBearing());
1906 int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
1907 if ((minLB + widthUsed) <= lineRect.width()) {
1908 // text fits in lineRect; use hscroll for alignment
1909 switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
1910 case Qt::AlignRight:
1911 d->hscroll = widthUsed - lineRect.width() + 1;
1912 break;
1913 case Qt::AlignHCenter:
1914 d->hscroll = (widthUsed - lineRect.width()) / 2;
1915 break;
1916 default:
1917 // Left
1918 d->hscroll = 0;
1919 break;
1920 }
1921 d->hscroll -= minLB;
1922 } else if (cix - d->hscroll >= lineRect.width()) {
1923 // text doesn't fit, cursor is to the right of lineRect (scroll right)
1924 d->hscroll = cix - lineRect.width() + 1;
1925 } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) {
1926 // text doesn't fit, cursor is to the left of lineRect (scroll left)
1927 d->hscroll = cix;
1928 } else if (widthUsed - d->hscroll < lineRect.width()) {
1929 // text doesn't fit, text document is to the left of lineRect; align
1930 // right
1931 d->hscroll = widthUsed - lineRect.width() + 1;
1932 }
1933 // the y offset is there to keep the baseline constant in case we have script changes in the text.
1934 QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
1935
1936 // draw text, selections and cursors
1937#ifndef QT_NO_STYLE_STYLESHEET
1938 if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style())) {
1939 cssStyle->styleSheetPalette(this, &panel, &pal);
1940 }
1941#endif
1942 p.setPen(pal.text().color());
1943
1944 int flags = QLineControl::DrawText;
1945
1946#ifdef QT_KEYPAD_NAVIGATION
1947 if (!QApplication::keypadNavigationEnabled() || hasEditFocus())
1948#endif
1949 if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){
1950 flags |= QLineControl::DrawSelections;
1951 // Palette only used for selections/mask and may not be in sync
1952 if(d->control->palette() != pal)
1953 d->control->setPalette(pal);
1954 }
1955
1956 // Asian users see an IM selection text as cursor on candidate
1957 // selection phase of input method, so the ordinary cursor should be
1958 // invisible if we have a preedit string.
1959 if (d->cursorVisible && !d->control->isReadOnly())
1960 flags |= QLineControl::DrawCursor;
1961
1962 d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth));
1963 d->control->draw(&p, topLeft, r, flags);
1964
1965}
1966
1967
1968#ifndef QT_NO_DRAGANDDROP
1969/*!\reimp
1970*/
1971void QLineEdit::dragMoveEvent(QDragMoveEvent *e)
1972{
1973 Q_D(QLineEdit);
1974 if (!d->control->isReadOnly() && e->mimeData()->hasFormat(QLatin1String("text/plain"))) {
1975 e->acceptProposedAction();
1976 d->control->moveCursor(d->xToPos(e->pos().x()), false);
1977 d->cursorVisible = true;
1978 update();
1979 }
1980}
1981
1982/*!\reimp */
1983void QLineEdit::dragEnterEvent(QDragEnterEvent * e)
1984{
1985 QLineEdit::dragMoveEvent(e);
1986}
1987
1988/*!\reimp */
1989void QLineEdit::dragLeaveEvent(QDragLeaveEvent *)
1990{
1991 Q_D(QLineEdit);
1992 if (d->cursorVisible) {
1993 d->cursorVisible = false;
1994 update();
1995 }
1996}
1997
1998/*!\reimp */
1999void QLineEdit::dropEvent(QDropEvent* e)
2000{
2001 Q_D(QLineEdit);
2002 QString str = e->mimeData()->text();
2003
2004 if (!str.isNull() && !d->control->isReadOnly()) {
2005 if (e->source() == this && e->dropAction() == Qt::CopyAction)
2006 deselect();
2007 int cursorPos = d->xToPos(e->pos().x());
2008 int selStart = cursorPos;
2009 int oldSelStart = d->control->selectionStart();
2010 int oldSelEnd = d->control->selectionEnd();
2011 d->control->moveCursor(cursorPos, false);
2012 d->cursorVisible = false;
2013 e->acceptProposedAction();
2014 insert(str);
2015 if (e->source() == this) {
2016 if (e->dropAction() == Qt::MoveAction) {
2017 if (selStart > oldSelStart && selStart <= oldSelEnd)
2018 setSelection(oldSelStart, str.length());
2019 else if (selStart > oldSelEnd)
2020 setSelection(selStart - str.length(), str.length());
2021 else
2022 setSelection(selStart, str.length());
2023 } else {
2024 setSelection(selStart, str.length());
2025 }
2026 }
2027 } else {
2028 e->ignore();
2029 update();
2030 }
2031}
2032
2033#endif // QT_NO_DRAGANDDROP
2034
2035#ifndef QT_NO_CONTEXTMENU
2036/*!
2037 Shows the standard context menu created with
2038 createStandardContextMenu().
2039
2040 If you do not want the line edit to have a context menu, you can set
2041 its \l contextMenuPolicy to Qt::NoContextMenu. If you want to
2042 customize the context menu, reimplement this function. If you want
2043 to extend the standard context menu, reimplement this function, call
2044 createStandardContextMenu() and extend the menu returned.
2045
2046 \snippet doc/src/snippets/code/src_gui_widgets_qlineedit.cpp 0
2047
2048 The \a event parameter is used to obtain the position where
2049 the mouse cursor was when the event was generated.
2050
2051 \sa setContextMenuPolicy()
2052*/
2053void QLineEdit::contextMenuEvent(QContextMenuEvent *event)
2054{
2055 QPointer<QMenu> menu = createStandardContextMenu();
2056 menu->exec(event->globalPos());
2057 delete menu;
2058}
2059
2060#if defined(Q_WS_WIN)
2061 extern bool qt_use_rtl_extensions;
2062#endif
2063
2064/*! This function creates the standard context menu which is shown
2065 when the user clicks on the line edit with the right mouse
2066 button. It is called from the default contextMenuEvent() handler.
2067 The popup menu's ownership is transferred to the caller.
2068*/
2069
2070QMenu *QLineEdit::createStandardContextMenu()
2071{
2072 Q_D(QLineEdit);
2073 QMenu *popup = new QMenu(this);
2074 popup->setObjectName(QLatin1String("qt_edit_menu"));
2075 QAction *action = 0;
2076
2077 if (!isReadOnly()) {
2078 action = popup->addAction(QLineEdit::tr("&Undo") + ACCEL_KEY(QKeySequence::Undo));
2079 action->setEnabled(d->control->isUndoAvailable());
2080 connect(action, SIGNAL(triggered()), SLOT(undo()));
2081
2082 action = popup->addAction(QLineEdit::tr("&Redo") + ACCEL_KEY(QKeySequence::Redo));
2083 action->setEnabled(d->control->isRedoAvailable());
2084 connect(action, SIGNAL(triggered()), SLOT(redo()));
2085
2086 popup->addSeparator();
2087 }
2088
2089#ifndef QT_NO_CLIPBOARD
2090 if (!isReadOnly()) {
2091 action = popup->addAction(QLineEdit::tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut));
2092 action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText()
2093 && d->control->echoMode() == QLineEdit::Normal);
2094 connect(action, SIGNAL(triggered()), SLOT(cut()));
2095 }
2096
2097 action = popup->addAction(QLineEdit::tr("&Copy") + ACCEL_KEY(QKeySequence::Copy));
2098 action->setEnabled(d->control->hasSelectedText()
2099 && d->control->echoMode() == QLineEdit::Normal);
2100 connect(action, SIGNAL(triggered()), SLOT(copy()));
2101
2102 if (!isReadOnly()) {
2103 action = popup->addAction(QLineEdit::tr("&Paste") + ACCEL_KEY(QKeySequence::Paste));
2104 action->setEnabled(!d->control->isReadOnly() && !QApplication::clipboard()->text().isEmpty());
2105 connect(action, SIGNAL(triggered()), SLOT(paste()));
2106 }
2107#endif
2108
2109 if (!isReadOnly()) {
2110 action = popup->addAction(QLineEdit::tr("Delete"));
2111 action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText());
2112 connect(action, SIGNAL(triggered()), d->control, SLOT(_q_deleteSelected()));
2113 }
2114
2115 if (!popup->isEmpty())
2116 popup->addSeparator();
2117
2118 action = popup->addAction(QLineEdit::tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll));
2119 action->setEnabled(!d->control->text().isEmpty() && !d->control->allSelected());
2120 d->selectAllAction = action;
2121 connect(action, SIGNAL(triggered()), SLOT(selectAll()));
2122
2123#if !defined(QT_NO_IM)
2124 QInputContext *qic = inputContext();
2125 if (qic) {
2126 QList<QAction *> imActions = qic->actions();
2127 for (int i = 0; i < imActions.size(); ++i)
2128 popup->addAction(imActions.at(i));
2129 }
2130#endif
2131
2132#if defined(Q_WS_WIN)
2133 if (!d->control->isReadOnly() && qt_use_rtl_extensions) {
2134#else
2135 if (!d->control->isReadOnly()) {
2136#endif
2137 popup->addSeparator();
2138 QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup);
2139 popup->addMenu(ctrlCharacterMenu);
2140 }
2141 return popup;
2142}
2143#endif // QT_NO_CONTEXTMENU
2144
2145/*! \reimp */
2146void QLineEdit::changeEvent(QEvent *ev)
2147{
2148 Q_D(QLineEdit);
2149 switch(ev->type())
2150 {
2151 case QEvent::ActivationChange:
2152 if (!palette().isEqual(QPalette::Active, QPalette::Inactive))
2153 update();
2154 break;
2155 case QEvent::FontChange:
2156 d->control->setFont(font());
2157 break;
2158 case QEvent::StyleChange:
2159 {
2160 QStyleOptionFrameV2 opt;
2161 initStyleOption(&opt);
2162 d->control->setPasswordCharacter(style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, this));
2163 }
2164 update();
2165 break;
2166 case QEvent::LayoutDirectionChange:
2167 d->control->setLayoutDirection(layoutDirection());
2168 break;
2169 default:
2170 break;
2171 }
2172 QWidget::changeEvent(ev);
2173}
2174
2175/*!
2176 \fn void QLineEdit::repaintArea(int a, int b)
2177
2178 Use update() instead.
2179*/
2180
2181/*!
2182 \fn void QLineEdit::cursorLeft(bool mark, int steps)
2183
2184 Use cursorForward() with a negative number of steps instead. For
2185 example, cursorForward(mark, -steps).
2186*/
2187
2188/*!
2189 \fn void QLineEdit::cursorRight(bool mark, int steps)
2190
2191 Use cursorForward() instead.
2192*/
2193
2194/*!
2195 \fn bool QLineEdit::frame() const
2196
2197 Use hasFrame() instead.
2198*/
2199
2200/*!
2201 \fn void QLineEdit::clearValidator()
2202
2203 Use setValidator(0) instead.
2204*/
2205
2206/*!
2207 \fn bool QLineEdit::hasMarkedText() const
2208
2209 Use hasSelectedText() instead.
2210*/
2211
2212/*!
2213 \fn QString QLineEdit::markedText() const
2214
2215 Use selectedText() instead.
2216*/
2217
2218/*!
2219 \fn void QLineEdit::setFrameRect(QRect)
2220 \internal
2221*/
2222
2223/*!
2224 \fn QRect QLineEdit::frameRect() const
2225 \internal
2226*/
2227/*!
2228 \enum QLineEdit::DummyFrame
2229 \internal
2230
2231 \value Box
2232 \value Sunken
2233 \value Plain
2234 \value Raised
2235 \value MShadow
2236 \value NoFrame
2237 \value Panel
2238 \value StyledPanel
2239 \value HLine
2240 \value VLine
2241 \value GroupBoxPanel
2242 \value WinPanel
2243 \value ToolBarPanel
2244 \value MenuBarPanel
2245 \value PopupPanel
2246 \value LineEditPanel
2247 \value TabWidgetPanel
2248 \value MShape
2249*/
2250
2251/*!
2252 \fn void QLineEdit::setFrameShadow(DummyFrame)
2253 \internal
2254*/
2255
2256/*!
2257 \fn DummyFrame QLineEdit::frameShadow() const
2258 \internal
2259*/
2260
2261/*!
2262 \fn void QLineEdit::setFrameShape(DummyFrame)
2263 \internal
2264*/
2265
2266/*!
2267 \fn DummyFrame QLineEdit::frameShape() const
2268 \internal
2269*/
2270
2271/*!
2272 \fn void QLineEdit::setFrameStyle(int)
2273 \internal
2274*/
2275
2276/*!
2277 \fn int QLineEdit::frameStyle() const
2278 \internal
2279*/
2280
2281/*!
2282 \fn int QLineEdit::frameWidth() const
2283 \internal
2284*/
2285
2286/*!
2287 \fn void QLineEdit::setLineWidth(int)
2288 \internal
2289*/
2290
2291/*!
2292 \fn int QLineEdit::lineWidth() const
2293 \internal
2294*/
2295
2296/*!
2297 \fn void QLineEdit::setMargin(int margin)
2298 Sets the width of the margin around the contents of the widget to \a margin.
2299
2300 Use QWidget::setContentsMargins() instead.
2301 \sa margin(), QWidget::setContentsMargins()
2302*/
2303
2304/*!
2305 \fn int QLineEdit::margin() const
2306 Returns the width of the margin around the contents of the widget.
2307
2308 Use QWidget::getContentsMargins() instead.
2309 \sa setMargin(), QWidget::getContentsMargins()
2310*/
2311
2312/*!
2313 \fn void QLineEdit::setMidLineWidth(int)
2314 \internal
2315*/
2316
2317/*!
2318 \fn int QLineEdit::midLineWidth() const
2319 \internal
2320*/
2321
2322QT_END_NAMESPACE
2323
2324#include "moc_qlineedit.cpp"
2325
2326#endif // QT_NO_LINEEDIT
Note: See TracBrowser for help on using the repository browser.