slint-ui/slint · error

component-factory not yet supported in C++

Error message

component-factory not yet supported in C++

What it means

The C++ generator's expression compiler hit an Expression::ComponentFactory value while lowering to C++ code. Component-factory values (used for dynamic component instantiation features in other backends) are not implemented in the C++ code generator, so compilation of the .slint file fails with this message. It fires when a .slint program uses a feature that produces a component factory (e.g. certain @children / repeated component references) and targets the C++ API.

Solutions

  1. Avoid component-factory typed properties/callbacks in .slint code compiled for the C++ generator; restructure to pass components differently
  2. Implement the component-factory codegen path in internal/compiler/generator/cpp.rs if C++ support is required
  3. Use a workaround such as storing the component as a plain element instance instead of a factory
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/compiler/generator/cpp.rs:4928 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16). Data as JSON: /api/errors/4021b16db0d598bf. Report an issue: GitHub.

Appendix: source

Thrown at internal/compiler/generator/cpp.rs:4922

            sub_expression,
            ctx,
        ),
        Expression::MinMax { ty, op, lhs, rhs } => {
            let ident = match op {
                MinMaxOp::Min => "min",
                MinMaxOp::Max => "max",
            };
            let lhs_code = compile_expression(lhs, ctx);
            let rhs_code = compile_expression(rhs, ctx);
            format!(
                r#"std::{ident}<{ty}>({lhs_code}, {rhs_code})"#,
                ty = ty.cpp_type().unwrap_or_default(),
                ident = ident,
                lhs_code = lhs_code,
                rhs_code = rhs_code
            )
        }
        Expression::EmptyComponentFactory => panic!("component-factory not yet supported in C++"),
        Expression::EmptyDataTransfer => "slint::DataTransfer()".into(),
        Expression::TranslationReference { format_args, string_index, plural } => {
            let args = compile_expression(format_args, ctx);
            match plural {
                Some(plural) => {
                    let plural = compile_expression(plural, ctx);
                    format!(
                        "slint::private_api::translate_from_bundle_with_plural(slint_translation_bundle_plural_{string_index}_str, slint_translation_bundle_plural_{string_index}_idx,  slint_translated_plural_rules, {args}, {plural})"
                    )
                }
                None => format!(
                    "slint::private_api::translate_from_bundle(slint_translation_bundle_{string_index}, {args})"
                ),
            }
        }
        Expression::Closure { arg_name, expression } => {
            let arg = ident(arg_name);
            let expr = compile_expression(expression, ctx);

View on GitHub (pinned to 3a7e700487)