- Extending Qt Creator Manual
- QtCreator
- BaseAspect
- Extending Qt Creator Manual 11.0.0-beta1

# BaseAspect Class

class Utils::BaseAspect

The `BaseAspect` class provides a common base for classes implementing aspects. More...

Header: | #include <BaseAspect>
Inherited By: | Utils::BoolAspect, Utils::ColorAspect, Utils::DoubleAspect, Utils::IntegerAspect, Utils::MultiSelectionAspect, Utils::SelectionAspect, Utils::StringAspect, Utils::StringListAspect, and Utils::TextDisplay

- List of all members, including inherited members

## Public Functions

| BaseAspect(Utils::AspectContainer *container = nullptr)
virtual | ~BaseAspect() override
virtual void | addToLayout(Layouting::LayoutItem &parent)
virtual void | apply()
virtual void | cancel()
QString | displayName() const
virtual void | fromMap(const QVariantMap &map)
QString | labelText() const
void | setAutoApply(bool on)
void | setDefaultValue(const QVariant &value)
void | setEnabler(Utils::BoolAspect *checker)
void | setLabelPixmap(const QPixmap &labelPixmap)
void | setLabelText(const QString &labelText)
void | setSettingsKey(const QString &key)
void | setSettingsKey(const QString &group, const QString &key)
void | setToolTip(const QString &tooltip)
void | setValue(const QVariant &value)
bool | setValueQuietly(const QVariant &value)
void | setVisible(bool visible)
QString | settingsKey() const
virtual void | toMap(QVariantMap &map) const

## Detailed Description

An aspect is a hunk of data like a property or collection of related properties of some object, together with a description of its behavior for common operations like visualizing or persisting.

Simple aspects are for example a boolean property represented by a QCheckBox in the user interface, or a string property represented by a PathChooser, selecting directories in the filesystem.

While aspects implementations usually have the ability to visualize and to persist their data, or use an ID, neither of these is mandatory.

## Member Function Documentation

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

Constructs a base aspect.

If container is non-null, the aspect is made known to the container.

### `[override virtual]` BaseAspect::~BaseAspect()

Destructs a BaseAspect.

### `[virtual]` void BaseAspect::addToLayout(Layouting::LayoutItem &parent)

Adds the visual representation of this aspect to the layout with the specified parent using a layout builder.

### `[virtual]` void BaseAspect::apply()

Updates this aspect's value from user-initiated changes in the widget.

This has only an effect if `isAutoApply` is false.

### `[virtual]` void BaseAspect::cancel()

Discard user changes in the widget and restore widget contents from aspect's value.

This has only an effect if `isAutoApply` is false.

### QString BaseAspect::displayName() const

Returns the string that should be used when this action appears in menus or other places that are typically used with Book style capitalization.

If no display name is set, the label text will be used as fallback.

### `[virtual]` void BaseAspect::fromMap(const QVariantMap &map)

Retrieves the internal value of this BaseAspect from the QVariantMap map.

### QString BaseAspect::labelText() const

Returns the current text for the separate label in the visual representation of this aspect.

See also setLabelText().

### void BaseAspect::setAutoApply(bool on)

Sets auto-apply mode. When auto-apply mode is on, user interaction to this aspect's widget will not modify the `value` of the aspect until `apply()` is called programmatically.

See also setSettingsKey().

### void BaseAspect::setDefaultValue(const QVariant &value)

Sets a default value and the current value for this aspect.

Note: The current value will be set silently to the same value. It is reasonable to only set default values in the setup phase of the aspect.

Default values will not be stored in settings.

### void BaseAspect::setEnabler(Utils::BoolAspect *checker)

Makes the enabled state of this aspect depend on the checked state of checker.

### void BaseAspect::setLabelPixmap(const QPixmap &labelPixmap)

Sets labelPixmap as pixmap for the separate label in the visual representation of this aspect.

### void BaseAspect::setLabelText(const QString &labelText)

Sets labelText as text for the separate label in the visual representation of this aspect.

See also labelText().

### void BaseAspect::setSettingsKey(const QString &key)

Sets the key to be used when accessing the settings.

See also settingsKey().

### void BaseAspect::setSettingsKey(const QString &group, const QString &key)

Sets the key and group to be used when accessing the settings.

See also settingsKey().

### void BaseAspect::setToolTip(const QString &tooltip)

Sets tooltip as tool tip for the visual representation of this aspect.

### void BaseAspect::setValue(const QVariant &value)

Sets value.

Emits `changed()` if the value changed.

### bool BaseAspect::setValueQuietly(const QVariant &value)

Sets value without emitting `changed()`.

Returns whether the value changed.

### void BaseAspect::setVisible(bool visible)

Shows or hides the visual representation of this aspect depending on the value of visible. By default, it is visible.

### QString BaseAspect::settingsKey() const

Returns the key to be used when accessing the settings.

See also setSettingsKey().

### `[virtual]` void BaseAspect::toMap(QVariantMap &map) const

Stores the internal value of this BaseAspect into the QVariantMap map.