Skip to content

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.

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++
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.

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.

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.

bool slint::testing::ElementHandle::is_valid() const

Returns true if the underlying element still exists; false otherwise.


© 2026 SixtyFPS GmbH