summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qlineedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qlineedit.cpp')
-rw-r--r--src/widgets/widgets/qlineedit.cpp53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index fe0d87d8c1..bd5e0b047e 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -276,7 +276,7 @@ QLineEdit::QLineEdit(QWidget* parent)
\sa text(), setMaxLength()
*/
QLineEdit::QLineEdit(const QString& contents, QWidget* parent)
- : QWidget(*new QLineEditPrivate, parent, 0)
+ : QWidget(*new QLineEditPrivate, parent, { })
{
Q_D(QLineEdit);
d->init(contents);
@@ -448,7 +448,7 @@ void QLineEdit::addAction(QAction *action, ActionPosition position)
{
Q_D(QLineEdit);
QWidget::addAction(action);
- d->addAction(action, 0, position);
+ d->addAction(action, nullptr, position);
}
/*!
@@ -642,15 +642,15 @@ void QLineEdit::setCompleter(QCompleter *c)
if (c == d->control->completer())
return;
if (d->control->completer()) {
- disconnect(d->control->completer(), 0, this, 0);
- d->control->completer()->setWidget(0);
+ disconnect(d->control->completer(), nullptr, this, nullptr);
+ d->control->completer()->setWidget(nullptr);
if (d->control->completer()->parent() == this)
delete d->control->completer();
}
d->control->setCompleter(c);
if (!c)
return;
- if (c->widget() == 0)
+ if (c->widget() == nullptr)
c->setWidget(this);
if (hasFocus()) {
QObject::connect(d->control->completer(), SIGNAL(activated(QString)),
@@ -685,7 +685,7 @@ QSize QLineEdit::sizeHint() const
Q_D(const QLineEdit);
ensurePolished();
QFontMetrics fm(font());
- const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
+ const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
const QMargins tm = d->effectiveTextMargins();
int h = qMax(fm.height(), qMax(14, iconSize - 2)) + 2 * QLineEditPrivate::verticalMargin
+ tm.top() + tm.bottom()
@@ -1200,18 +1200,24 @@ QMargins QLineEdit::textMargins() const
Unset the mask and return to normal QLineEdit operation by passing
an empty string ("").
- The table below shows the characters that can be used in an input mask.
- A space character, the default character for a blank, is needed for cases
- where a character is \e{permitted but not required}.
+ The input mask is an input template string. It can contain the following elements:
+ \table
+ \row \li Mask Characters \li Defines the class of input characters that are
+ considered valid in this position
+ \row \li Meta Characters \li Various special meanings
+ \row \li Separators \li All other characters are regarded as immutable separators
+ \endtable
+
+ The following table shows the mask and meta characters that can be used in an input mask.
\table
- \header \li Character \li Meaning
+ \header \li Mask Character \li Meaning
\row \li \c A \li ASCII alphabetic character required. A-Z, a-z.
\row \li \c a \li ASCII alphabetic character permitted but not required.
\row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9.
\row \li \c n \li ASCII alphanumeric character permitted but not required.
- \row \li \c X \li Any character required.
- \row \li \c x \li Any character permitted but not required.
+ \row \li \c X \li Any non-blank character required.
+ \row \li \c x \li Any non-blank character permitted but not required.
\row \li \c 9 \li ASCII digit required. 0-9.
\row \li \c 0 \li ASCII digit permitted but not required.
\row \li \c D \li ASCII digit required. 1-9.
@@ -1221,19 +1227,28 @@ QMargins QLineEdit::textMargins() const
\row \li \c h \li Hexadecimal character permitted but not required.
\row \li \c B \li Binary character required. 0-1.
\row \li \c b \li Binary character permitted but not required.
+ \header \li Meta Character \li Meaning
\row \li \c > \li All following alphabetic characters are uppercased.
\row \li \c < \li All following alphabetic characters are lowercased.
\row \li \c ! \li Switch off case conversion.
+ \row \li \c {;c} \li Terminates the input mask and sets the \e{blank} character to \e{c}.
\row \li \c {[ ] { }} \li Reserved.
\row \li \tt{\\} \li Use \tt{\\} to escape the special
characters listed above to use them as
separators.
\endtable
- The mask consists of a string of mask characters and separators,
- optionally followed by a semicolon and the character used for
- blanks. The blank characters are always removed from the text
- after editing.
+ When created or cleared, the line edit will be filled with a copy of the
+ input mask string where the meta characters have been removed, and the mask
+ characters have been replaced with the \e{blank} character (by default, a
+ \c space).
+
+ When an input mask is set, the text() method returns a modified copy of the
+ line edit content where all the \e{blank} characters have been removed. The
+ unmodified content can be read using displayText().
+
+ The hasAcceptableInput() method returns false if the current content of the
+ line edit does not fulfil the requirements of the input mask.
Examples:
\table
@@ -1242,7 +1257,7 @@ QMargins QLineEdit::textMargins() const
\row \li \c HH:HH:HH:HH:HH:HH;_ \li MAC address
\row \li \c 0000-00-00 \li ISO Date; blanks are \c space
\row \li \c >AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;# \li License number;
- blanks are \c - and all (alphabetic) characters are converted to
+ blanks are \c{#} and all (alphabetic) characters are converted to
uppercase.
\endtable
@@ -1938,7 +1953,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e)
#endif
#if QT_CONFIG(completer)
if (d->control->completer()) {
- QObject::disconnect(d->control->completer(), 0, this, 0);
+ QObject::disconnect(d->control->completer(), nullptr, this, nullptr);
}
#endif
QWidget::focusOutEvent(e);
@@ -2177,7 +2192,7 @@ QMenu *QLineEdit::createStandardContextMenu()
Q_D(QLineEdit);
QMenu *popup = new QMenu(this);
popup->setObjectName(QLatin1String("qt_edit_menu"));
- QAction *action = 0;
+ QAction *action = nullptr;
if (!isReadOnly()) {
action = popup->addAction(QLineEdit::tr("&Undo") + ACCEL_KEY(QKeySequence::Undo));