slint::testing::ElementHandle Class
class ElementHandle;#include <slint-testing.h>A handle to an element for querying accessible properties, intended for testing purposes.
Public Static Functions
Section titled “Public Static Functions” visit_elements
Section titled “ visit_elements”static auto slint::testing::ElementHandle::visit_elements(const ComponentHandle< T > &component, Visitor visitor) -> std::invoke_result_t< Visitor, ElementHandle >
Visits visible elements within a component and calls the visitor for each of them.
The visitor must be a callable object that accepts an ElementHandle and returns either void, or a type that can be converted to bool.
- If the visitor returns
void, the visitation continues until all elements have been visited. - If the visitor returns a type that can be converted to
bool, the visitation continues as long as the conversion result is false; otherwise, it stops, returning that value. If the visitor never returns something that converts to true, then the function returns a default constructed value;
auto element = ElementHandle::visit_elements(component, [&](const ElementHandle& eh) -> std::optional<ElementHandle> { return eh.id() == "Foo::bar" ? std::make_optional(eh) : std::nullopt;}); find_by_accessible_label
Section titled “ find_by_accessible_label”static SharedVector< ElementHandle > slint::testing::ElementHandle::find_by_accessible_label(const ComponentHandle< T > &component, std::string_view label)
Find all elements matching the given accessible label.
find_by_element_id
Section titled “ find_by_element_id”static SharedVector< ElementHandle > slint::testing::ElementHandle::find_by_element_id(const ComponentHandle< T > &component, std::string_view element_id)
Find all elements matching the given element_id.
find_by_element_type_name
Section titled “ find_by_element_type_name”static SharedVector< ElementHandle > slint::testing::ElementHandle::find_by_element_type_name(const ComponentHandle< T > &component, std::string_view type_name)
Find all elements matching the given type name.
Public Functions
Section titled “Public Functions” is_valid
Section titled “ is_valid”bool slint::testing::ElementHandle::is_valid() const
Returns true if the underlying element still exists; false otherwise.
std::optional< SharedString > slint::testing::ElementHandle::id() const
Returns the element’s qualified id. Returns None if the element is not valid anymore or the element does not have an id. A qualified id consists of the name of the surrounding component as well as the provided local name, separate by a double colon.
,no-previewcomponent PushButton { /* .. *‍/}
export component App { mybutton := PushButton { } // known as `App::mybutton` PushButton { } // no id} type_name
Section titled “ type_name”std::optional< SharedString > slint::testing::ElementHandle::type_name() const
Returns the element’s type name; std::nullopt if the element is not valid anymore.
,no-previewcomponent PushButton { /* .. *‍/}
export component App { mybutton := PushButton { } // type_name is "PushButton"}std::optional< SharedVector< SharedString > > slint::testing::ElementHandle::bases() const
Returns the element’s base types as an iterator; None if the element is not valid anymore.
,no-previewcomponent ButtonBase { /* .. *‍/}
component PushButton inherits ButtonBase { /* .. *‍/}
export component App { mybutton := PushButton { } // bases will be ["ButtonBase"]} layout_kind
Section titled “ layout_kind”std::optional< slint::testing::LayoutKind > slint::testing::ElementHandle::layout_kind() const
Returns the layout kind if this element is a layout container; std::nullopt if the element is not a layout or is not valid anymore.
accessible_role
Section titled “ accessible_role”std::optional< slint::testing::AccessibleRole > slint::testing::ElementHandle::accessible_role() const
Returns the value of the element’s accessible-role property, if present. Use this property to locate elements by their type/role, i.e. buttons, checkboxes, etc.
accessible_label
Section titled “ accessible_label”std::optional< SharedString > slint::testing::ElementHandle::accessible_label() const
Returns the accessible-label of that element, if any.
accessible_enabled
Section titled “ accessible_enabled”std::optional< bool > slint::testing::ElementHandle::accessible_enabled() const
Returns the accessible-enabled of that element, if any.
accessible_value
Section titled “ accessible_value”std::optional< SharedString > slint::testing::ElementHandle::accessible_value() const
Returns the accessible-value of that element, if any.
accessible_placeholder_text
Section titled “ accessible_placeholder_text”std::optional< SharedString > slint::testing::ElementHandle::accessible_placeholder_text() const
Returns the accessible-placeholder-text of that element, if any.
accessible_description
Section titled “ accessible_description”std::optional< SharedString > slint::testing::ElementHandle::accessible_description() const
Returns the accessible-description of that element, if any.
accessible_id
Section titled “ accessible_id”std::optional< SharedString > slint::testing::ElementHandle::accessible_id() const
Returns the accessible-id of that element, if any.
accessible_value_maximum
Section titled “ accessible_value_maximum”std::optional< float > slint::testing::ElementHandle::accessible_value_maximum() const
Returns the accessible-value-maximum of that element, if any.
accessible_value_minimum
Section titled “ accessible_value_minimum”std::optional< float > slint::testing::ElementHandle::accessible_value_minimum() const
Returns the accessible-value-minimum of that element, if any.
accessible_value_step
Section titled “ accessible_value_step”std::optional< float > slint::testing::ElementHandle::accessible_value_step() const
Returns the accessible-value-step of that element, if any.
accessible_checked
Section titled “ accessible_checked”std::optional< bool > slint::testing::ElementHandle::accessible_checked() const
Returns the accessible-checked of that element, if any.
accessible_checkable
Section titled “ accessible_checkable”std::optional< bool > slint::testing::ElementHandle::accessible_checkable() const
Returns the accessible-checkable of that element, if any.
accessible_item_selected
Section titled “ accessible_item_selected”std::optional< bool > slint::testing::ElementHandle::accessible_item_selected() const
Returns the accessible-item-selected of that element, if any.
accessible_item_selectable
Section titled “ accessible_item_selectable”std::optional< bool > slint::testing::ElementHandle::accessible_item_selectable() const
Returns the accessible-item-selectable of that element, if any.
accessible_item_index
Section titled “ accessible_item_index”std::optional< size_t > slint::testing::ElementHandle::accessible_item_index() const
Returns the accessible-item-index of that element, if any.
accessible_item_count
Section titled “ accessible_item_count”std::optional< size_t > slint::testing::ElementHandle::accessible_item_count() const
Returns the accessible-item-count of that element, if any.
accessible_expanded
Section titled “ accessible_expanded”std::optional< bool > slint::testing::ElementHandle::accessible_expanded() const
Returns the accessible-expanded of that element, if any.
accessible_expandable
Section titled “ accessible_expandable”std::optional< bool > slint::testing::ElementHandle::accessible_expandable() const
Returns the accessible-expandable of that element, if any.
accessible_read_only
Section titled “ accessible_read_only”std::optional< bool > slint::testing::ElementHandle::accessible_read_only() const
Returns the accessible-read-only of that element, if any.
accessible_orientation
Section titled “ accessible_orientation”std::optional< Orientation > slint::testing::ElementHandle::accessible_orientation() const
Returns the accessible-orientation of that element, if any.
accessible_live_region
Section titled “ accessible_live_region”std::optional< AccessibleLiveRegion > slint::testing::ElementHandle::accessible_live_region() const
Returns the accessible-live-region of that element, if any.
invoke_accessible_expand_action
Section titled “ invoke_accessible_expand_action”void slint::testing::ElementHandle::invoke_accessible_expand_action() const
Invokes the expand accessibility action of that element (accessible-action-expand).
set_accessible_value
Section titled “ set_accessible_value”void slint::testing::ElementHandle::set_accessible_value(SharedString value) const
Sets the accessible-value of that element.
Setting the value will invoke the accessible-action-set-value callback.
invoke_accessible_increment_action
Section titled “ invoke_accessible_increment_action”void slint::testing::ElementHandle::invoke_accessible_increment_action() const
Invokes the increase accessibility action of that element (accessible-action-increment).
invoke_accessible_decrement_action
Section titled “ invoke_accessible_decrement_action”void slint::testing::ElementHandle::invoke_accessible_decrement_action() const
Invokes the decrease accessibility action of that element (accessible-action-decrement).
invoke_accessible_default_action
Section titled “ invoke_accessible_default_action”void slint::testing::ElementHandle::invoke_accessible_default_action() const
Invokes the default accessibility action of that element (accessible-action-default).
LogicalSize slint::testing::ElementHandle::size() const
Returns the size of this element.
absolute_position
Section titled “ absolute_position”LogicalPosition slint::testing::ElementHandle::absolute_position() const
Returns the absolute position of this element.
© 2026 SixtyFPS GmbH