slint::interpreter::ComponentCompiler Class
class ComponentCompiler;#include <slint-interpreter.h>ComponentCompiler is the entry point to the Slint interpreter that can be used to load .slint files or compile them on-the-fly from a string (using build_from_source()) or from a path (using build_from_path())
Public Functions
Section titled “Public Functions” ComponentCompiler
Section titled “ ComponentCompiler”slint::interpreter::ComponentCompiler::ComponentCompiler()
Constructs a new ComponentCompiler instance.
~ComponentCompiler
Section titled “ ~ComponentCompiler”slint::interpreter::ComponentCompiler::~ComponentCompiler()
Destroys this ComponentCompiler.
set_include_paths
Section titled “ set_include_paths”void slint::interpreter::ComponentCompiler::set_include_paths(const slint::SharedVector<slint::SharedString> &paths)
Sets the include paths used for looking up .slint imports to the specified vector of paths. These paths come before the include paths of the project file.
set_style
Section titled “ set_style”void slint::interpreter::ComponentCompiler::set_style(std::string_view style)
Sets the style to be used for widgets.
slint::SharedString slint::interpreter::ComponentCompiler::style() const
Returns the widget style the compiler is currently using when compiling .slint files.
set_translation_domain
Section titled “ set_translation_domain”void slint::interpreter::ComponentCompiler::set_translation_domain(std::string_view domain)
Sets the domain used for translations.
set_file_loader
Section titled “ set_file_loader”void slint::interpreter::ComponentCompiler::set_file_loader(F callback)
Sets a custom file loader for the compiler. The callback is invoked with a const std::filesystem::path& and should return the file contents as a std::optional<std::string>, throw an std::exception, or return std::nullopt to use default resolution behaviour. [](const std::filesystem::path& path) -> std::optional<std::string>
include_paths
Section titled “ include_paths”slint::SharedVector<slint::SharedString> slint::interpreter::ComponentCompiler::include_paths() const
Returns the include paths the component compiler is currently configured with.
diagnostics
Section titled “ diagnostics”slint::SharedVector<Diagnostic> slint::interpreter::ComponentCompiler::diagnostics() const
Returns the diagnostics that were produced in the last call to build_from_path() or build_from_source().
build_from_source
Section titled “ build_from_source”std::optional<ComponentDefinition> slint::interpreter::ComponentCompiler::build_from_source(std::string_view source_code, std::string_view path)
Compile some .slint code into a ComponentDefinition
The path argument will be used for diagnostics and to compute relative paths while importing. Both source_code and path must be UTF-8 encoded; otherwise this function fails.
Returns the compiled ComponentDefinition if there were no errors.
Any diagnostics produced during the compilation, such as warnings or errors, are collected in this ComponentCompiler and can be retrieved after the call using the diagnostics() function.
Diagnostics from previous calls are cleared when calling this function.
build_from_path
Section titled “ build_from_path”std::optional<ComponentDefinition> slint::interpreter::ComponentCompiler::build_from_path(std::string_view path)
Compile a .slint file into a ComponentDefinition
path must be UTF-8 encoded; otherwise this function fails.
If path is a directory, Slint loads the project file (slint-project.json) inside that directory. The project file provides the settings not set on this compiler. It must contain a main entry, which specifies the .slint file the compiler loads. A .slint file path compiles without loading a project file.
Returns the compiled ComponentDefinition if there were no errors.
Any diagnostics produced during the compilation, such as warnings or errors, are collected in this ComponentCompiler and can be retrieved after the call using the diagnostics() function.
Diagnostics from previous calls are cleared when calling this function.
build_from_path
Section titled “ build_from_path”std::optional<ComponentDefinition> slint::interpreter::ComponentCompiler::build_from_path(const P &path)
Compile the .slint file at path into a ComponentDefinition, like build_from_path(std::string_view).
Use this overload for paths that may not be UTF-8 encoded, such as paths obtained from std::filesystem.
© 2026 SixtyFPS GmbH