- Extending Qt Creator Manual
- QtCreator
- StringAspect
- Extending Qt Creator Manual 13.0.0

# StringAspect Class

class Utils::StringAspect

A string aspect is a string-like property of some object, together with a description of its behavior for common operations like visualizing or persisting. More...

Header: | #include <StringAspect>
Inherits: | Utils::TypedAspect

- List of all members, including inherited members

## Public Types

enum | DisplayStyle { LabelDisplay, LineEditDisplay, TextEditDisplay, PathChooserDisplay, PasswordLineEditDisplay }

## Public Functions

| StringAspect(Utils::AspectContainer *container = nullptr)
void | makeCheckable(Utils::CheckBoxPlacement checkBoxPlacement, const QString &checkerLabel, const Utils::Key &checkerKey)
void | setDisplayFilter(const std::function<QString (const QString &)> &displayFilter)
void | setDisplayStyle(Utils::StringAspect::DisplayStyle displayStyle)
void | setElideMode(Qt::TextElideMode elideMode)
void | setHistoryCompleter(const Utils::Key &historyCompleterKey)
void | setPlaceHolderText(const QString &placeHolderText)

## Reimplemented Public Functions

virtual void | fromMap(const Utils::Store &map) override
virtual void | toMap(Utils::Store &map) const override

## Detailed Description

String aspects can represent for example a parameter for an external commands, paths in a file system, or simply strings.

The string can be displayed using a QLabel, QLineEdit, QTextEdit or Utils::PathChooser.

The visual representation often contains a label in front of the display of the actual value.

## Member Type Documentation

### enum StringAspect::DisplayStyle

The DisplayStyle enum describes the main visual characteristics of a string aspect.

Constant | Value | Description
--- | --- | ---
`Utils::StringAspect::LabelDisplay` | `0` | Based on QLabel, used for text that cannot be changed by the user in this place, for example names of executables that are defined in the build system.
`Utils::StringAspect::LineEditDisplay` | `1` | Based on QLineEdit, used for user-editable strings that usually fit on a line.
`Utils::StringAspect::TextEditDisplay` | `2` | Based on QTextEdit, used for user-editable strings that often do not fit on a line.
`Utils::StringAspect::PathChooserDisplay` | ? | Based on Utils::PathChooser.
`Utils::StringAspect::PasswordLineEditDisplay` | `3` | Based on QLineEdit, used for password strings

See also Utils::PathChooser.

## Member Function Documentation

### StringAspect::StringAspect(Utils::AspectContainer *container = nullptr)

Constructs the string aspect container.

### `[override virtual]` void StringAspect::fromMap(const Utils::Store &map)

Reimplements: BaseAspect::fromMap(const Utils::Store &map).

### void StringAspect::makeCheckable(Utils::CheckBoxPlacement checkBoxPlacement, const QString &checkerLabel, const Utils::Key &checkerKey)

Adds a check box with a checkerLabel according to checkBoxPlacement to the line edit.

The state of the check box is made persistent when using a non-emtpy checkerKey.

### void StringAspect::setDisplayFilter(const std::function<QString (const QString &)> &displayFilter)

Sets a displayFilter for fine-tuning the visual appearance of the value of this string aspect.

### void StringAspect::setDisplayStyle(Utils::StringAspect::DisplayStyle displayStyle)

Selects the main display characteristics of the aspect according to displayStyle.

Note: Not all StringAspect features are available with all display styles.

See also Utils::StringAspect::DisplayStyle.

### void StringAspect::setElideMode(Qt::TextElideMode elideMode)

Sets elideMode as label elide mode.

### void StringAspect::setHistoryCompleter(const Utils::Key &historyCompleterKey)

Sets historyCompleterKey as key for the history completer settings for line edits and path chooser displays.

See also Utils::PathChooser::setExpectedKind().

### void StringAspect::setPlaceHolderText(const QString &placeHolderText)

Sets placeHolderText as place holder for line and text displays.

### `[override virtual]` void StringAspect::toMap(Utils::Store &map) const

Reimplements: BaseAspect::toMap(Utils::Store &map) const.