A line edit which automatically validates its input and shows a visual indicator for invalid inputs.
More...
#include <validatinglineedit.h>
|
void | onTextChanged (const QString &new_text) |
| Connected to this line edits textChanged signal. Updates the visual indicator.
|
|
|
ValidationMode | validation_mode_ |
| Determines how the input text is validated, see ValidationMode modes.
|
|
std::function< bool(QString)> | validator_ = [](QString s) { return true; } |
| If the validation mode is set to VALID_CUSTOM, this function will be called and be passed the current input text as argument, whenever the text is changed. The new text is valid, if the function returns true.
|
|
bool | accept_empty_paths_ = false |
| If true: Empty paths will be accepted in VALID_PATH_EXISTS.
|
|
bool | show_status_tooltip_ = true |
| If true: Use the tooltip to display a reason for input rejection.
|
|
A line edit which automatically validates its input and shows a visual indicator for invalid inputs.
◆ ValidationMode
Type of validation to be applied.
Enumerator |
---|
VALID_NONE | All text is valid.
|
VALID_NOT_EMPTY | Requires text to not be an empty string.
|
VALID_PATH_EXISTS | Requires text to be a path to an existing file or directory.
|
VALID_CUSTOM | Uses a custom validation function.
|
VALID_IS_EXISTING_FILE | Requires text to be a path to an existing file.
|
VALID_IS_EXISTING_DIRECTORY | Requires text to be a path to an existing directory.
|
◆ ValidatingLineEdit() [1/2]
Calls QLineEdit constructor and sets the validation mode.
- Parameters
-
parent | Parent widget. |
mode | Validation mode to use. |
◆ ValidatingLineEdit() [2/2]
Calls QLineEdit constructor and sets the validation mode.
- Parameters
-
contents | Initial text for this line edit. |
parent | Parent widget. |
mode | Validation mode to use. |
◆ acceptsEmptyPaths()
bool ValidatingLineEdit::acceptsEmptyPaths |
( |
| ) |
const |
Returns whether or not an empty path will be accepted.
- Returns
- The state.
◆ hasValidText()
bool ValidatingLineEdit::hasValidText |
( |
| ) |
|
Checks if the current text is valid.
- Returns
- True if the text is valid.
◆ onTextChanged
void ValidatingLineEdit::onTextChanged |
( |
const QString & | new_text | ) |
|
|
privateslot |
Connected to this line edits textChanged signal. Updates the visual indicator.
- Parameters
-
new_text | The new display text |
◆ setAcceptsEmptyPaths()
void ValidatingLineEdit::setAcceptsEmptyPaths |
( |
bool | accept | ) |
|
Sets whether or not an empty path will be accepted.
- Parameters
-
◆ setCustomValidator()
void ValidatingLineEdit::setCustomValidator |
( |
std::function< bool(QString)> | validator | ) |
|
Sets a new custom validator function. Does not affect validation mode.
- Parameters
-
validator | If the validation mode is set to VALID_CUSTOM, this function will be called and be passed the current input text as argument, whenever the text is changed. The new text is valid, if the function returns true. |
◆ setShowStatusTooltip()
void ValidatingLineEdit::setShowStatusTooltip |
( |
bool | show | ) |
|
Sets whether or not the tooltip is used to show a reason for input rejection.
- Parameters
-
◆ setValidationMode()
Changes the validation mode to the new mode.
- Parameters
-
◆ showsStatusTooltip()
bool ValidatingLineEdit::showsStatusTooltip |
( |
| ) |
const |
Returns whether or not the tooltip is used to show a reason for input rejection.
- Returns
- The status.
The documentation for this class was generated from the following files: