slint::testing::ElementHandle Class
class ElementHandle;C++
#include <slint-testing.h>C++
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 std::invoke_result_t<Visitor, ElementHandle> slint::testing::ElementHandle::visit_elements(const ComponentHandle<T> &component, Visitor visitor)
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;});C++
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.
© 2026 SixtyFPS GmbH