Adds a value to the variant being built.
The value to add (must match the expected element type)
Closes the current container being built.
Opens a new subcontainer of the specified type.
The type of the subcontainer to open
StaticnewCreates a new VariantBuilder for the specified type.
The type of variant to build
A new VariantBuilder instance
A utility class for building complex GVariant structures incrementally.
VariantBuilder is useful when you need to construct variants dynamically or when dealing with complex nested structures. It provides a way to build variants step by step rather than constructing the entire structure at once.
Example