Conditional Values

Use a conditional value when only a property changes. Its condition must be a parenthesized Rust expression, followed by ?, the value for true, and the value for false.

Link {
    text: "Documentation"
    href: "/docs"
    background: (request.page == "docs") ? theme.selected : transparent
    color: (request.page == "docs") ? theme.accent : theme.text
}

Both result values must be valid QTML values: a quoted string, bare value, binding, or imported token reference. Use an if statement instead when the component tree itself needs to change.

Text {
    text: (user.is_admin) ? "Administrator" : "Member"
}