diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-03-27 14:10:43 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-04-01 21:37:48 +0200 |
commit | 5c1bc5c8a41e9d4b40161eae1413bcb69325dd8f (patch) | |
tree | 8206164a54fd4acc3b87a227d5107e40ea1be12d /src/widgets/widgets/qlineedit.cpp | |
parent | 7ed097b31f7e15812144c360021872cf8f11821e (diff) |
QLineEdit: clarify the impact of using validators
Values that are validated as Intermediate are possible to enter, but
returnPressed and editingFinished signals are not emitted.
Fixes: QTBUG-82915
Change-Id: I3e194cd6ee93b3402090117b67044cf3663a232e
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/widgets/widgets/qlineedit.cpp')
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index c578710f99..401a62aff3 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -599,9 +599,17 @@ const QValidator * QLineEdit::validator() const } /*! - Sets this line edit to only accept input that the validator, \a v, - will accept. This allows you to place any arbitrary constraints on - the text which may be entered. + Sets the validator for values of line edit to \a v. + + The line edit's returnPressed() and editingFinished() signals will only + be emitted if \a v validates the line edit's content as \l{QValidator::}{Acceptable}. + The user may change the content to any \l{QValidator::}{Intermediate} + value during editing, but will be prevented from editing the text to a + value that \a v validates as \l{QValidator::}{Invalid}. + + This allows you to constrain the text that shall finally be entered when editing is + done, while leaving users with enough freedom to edit the text from one valid state + to another. If \a v == 0, setValidator() removes the current input validator. The initial setting is to have no input validator (i.e. any input @@ -1439,7 +1447,7 @@ void QLineEdit::copy() const Inserts the clipboard's text at the cursor position, deleting any selected text, providing the line edit is not \l{QLineEdit::readOnly}{read-only}. - If the end result would not be acceptable to the current + If the end result would be invalid to the current \l{setValidator()}{validator}, nothing happens. \sa copy(), cut() |