FancyLineEdit Class

class Utils::FancyLineEdit

The FancyLineEdit class is an enhanced line edit with several opt-in features. More...

Header: #include <FancyLineEdit>
Inherits: Utils::CompletingLineEdit
Inherited By:

Utils::ClassNameValidatingLineEdit and Utils::FileNameValidatingLineEdit

Public Functions

void setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &fn)

Static Public Members

Utils::FancyLineEdit::ValidationFunction defaultValidationFunction()

Detailed Description

A FancyLineEdit instance can have:

  • An embedded pixmap on one side that is connected to a menu.
  • A grayed hintText (like "Type Here to") when not focused and empty. When connecting to the changed signals and querying text, one has to be aware that the text is set to that hint text if isShowingHintText() returns true (that is, does not contain valid user input).
  • A history completer.
  • The ability to validate the contents of the text field by setting the validationFunction.

When invalid, the text color will turn red and a tooltip will contain the error message. This approach is less intrusive than a QValidator which will prevent the user from entering certain characters.

A visible hint text results validation to be in state 'DisplayingInitialText', which is not valid, but is not marked red.

Member Function Documentation

[static] Utils::FancyLineEdit::ValidationFunction FancyLineEdit::defaultValidationFunction()

Returns the default validation function, which synchonously executes the line edit's validator.

See also setValidationFunction().

void FancyLineEdit::setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &fn)

Set a synchronous or asynchronous validation function fn. Asynchronous validation functions can continue to run after destruction of the FancyLineEdit instance. During shutdown asynchronous validation functions can continue to run until before the plugin instances are deleted (at that point the plugin manager waits for them to finish before continuing).

See also defaultValidationFunction().

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.