FancyLineEdit 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 Types
enum | Side { Left, Right } |
enum | State { Invalid, DisplayingInitialText, Valid } |
typedef | ValidationFunction |
Properties
- errorColor : QColor
- initialText : QString
- okColor : QColor
Public Functions
FancyLineEdit(QWidget *parent = 0) | |
~FancyLineEdit() | |
QAbstractButton * | button(Side side) const |
QIcon | buttonIcon(Side side) const |
QMenu * | buttonMenu(Side side) const |
QColor | errorColor() const |
QString | errorMessage() const |
bool | hasAutoHideButton(Side side) const |
bool | hasMenuTabFocusTrigger(Side side) const |
QString | initialText() const |
bool | isButtonVisible(Side side) const |
bool | isValid() const |
QColor | okColor() const |
void | onEditingFinished() |
void | setAutoHideButton(Side side, bool h) |
void | setButtonFocusPolicy(Side side, Qt::FocusPolicy policy) |
void | setButtonIcon(Side side, const QIcon &icon) |
void | setButtonMenu(Side side, QMenu *menu) |
void | setButtonToolTip(Side side, const QString &) |
void | setButtonVisible(Side side, bool visible) |
void | setErrorColor(const QColor &c) |
void | setFiltering(bool on) |
void | setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory = false) |
void | setInitialText(const QString &) |
void | setMenuTabFocusTrigger(Side side, bool v) |
void | setOkColor(const QColor &c) |
void | setSpecialCompleter(QCompleter *completer) |
void | setValidationFunction(const ValidationFunction &fn) |
State | state() const |
void | validate() |
Signals
void | buttonClicked(Utils::FancyLineEdit::Side side) |
void | filterChanged(const QString &) |
void | leftButtonClicked() |
void | rightButtonClicked() |
void | validChanged(bool validState) |
void | validReturnPressed() |
Static Public Members
ValidationFunction | defaultValidationFunction() |
Protected Functions
virtual QString | fixInputString(const QString &string) |
virtual void | handleChanged(const QString &) |
void | resizeEvent(QResizeEvent *e) |
- 2 protected functions inherited from Utils::CompletingLineEdit
Detailed Description
The FancyLineEdit class is an enhanced line edit with several opt-in features.
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 overriding virtual
validate()
function in derived clases.
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 Type Documentation
enum FancyLineEdit::Side
enum FancyLineEdit::State
typedef FancyLineEdit::ValidationFunction
Property Documentation
errorColor : QColor
Access functions:
QColor | errorColor() const |
void | setErrorColor(const QColor &c) |
initialText : QString
Access functions:
QString | initialText() const |
void | setInitialText(const QString &) |
okColor : QColor
Access functions:
QColor | okColor() const |
void | setOkColor(const QColor &c) |
Member Function Documentation
FancyLineEdit::FancyLineEdit(QWidget *parent = 0)
Default constructs an instance of FancyLineEdit.
FancyLineEdit::~FancyLineEdit()
Destroys the instance of FancyLineEdit.
QAbstractButton *FancyLineEdit::button(Side side) const
[signal]
void FancyLineEdit::buttonClicked(Utils::FancyLineEdit::Side side)
QIcon FancyLineEdit::buttonIcon(Side side) const
See also setButtonIcon().
QMenu *FancyLineEdit::buttonMenu(Side side) const
See also setButtonMenu().
[static]
ValidationFunction FancyLineEdit::defaultValidationFunction()
QString FancyLineEdit::errorMessage() const
[signal]
void FancyLineEdit::filterChanged(const QString &)
[virtual protected]
QString FancyLineEdit::fixInputString(const QString &string)
[virtual protected]
void FancyLineEdit::handleChanged(const QString &)
bool FancyLineEdit::hasAutoHideButton(Side side) const
bool FancyLineEdit::hasMenuTabFocusTrigger(Side side) const
bool FancyLineEdit::isButtonVisible(Side side) const
bool FancyLineEdit::isValid() const
[signal]
void FancyLineEdit::leftButtonClicked()
void FancyLineEdit::onEditingFinished()
[protected]
void FancyLineEdit::resizeEvent(QResizeEvent *e)
[signal]
void FancyLineEdit::rightButtonClicked()
void FancyLineEdit::setAutoHideButton(Side side, bool h)
See also hasAutoHideButton().
void FancyLineEdit::setButtonFocusPolicy(Side side, Qt::FocusPolicy policy)
void FancyLineEdit::setButtonIcon(Side side, const QIcon &icon)
See also buttonIcon().
void FancyLineEdit::setButtonMenu(Side side, QMenu *menu)
See also buttonMenu().
void FancyLineEdit::setButtonToolTip(Side side, const QString &)
void FancyLineEdit::setButtonVisible(Side side, bool visible)
See also isButtonVisible().
void FancyLineEdit::setFiltering(bool on)
void FancyLineEdit::setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory = false)
void FancyLineEdit::setMenuTabFocusTrigger(Side side, bool v)
See also hasMenuTabFocusTrigger().