mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
Clarify model handling in C++ interpreter slightly
* Remove `Value::to_model()` as it is not implemented * Document that models can be passed to .60 array/object properties * Add a test for the extraction / setting behavior of arrays.
This commit is contained in:
parent
b875a19310
commit
25a1e666d9
2 changed files with 42 additions and 4 deletions
|
@ -220,6 +220,12 @@ private:
|
|||
/// It is also possible to query the type the value holds by calling the Value::type()
|
||||
/// function.
|
||||
///
|
||||
/// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value>
|
||||
/// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a
|
||||
/// property in your .60 code that was declared to be either an array (`property <[sometype]> foo;`)
|
||||
/// or an object literal (`property <{foo: string, bar: int}> myprop;`). Such properties are dynamic
|
||||
/// and accept models implemented in C++.
|
||||
///
|
||||
/// ```
|
||||
/// Value v(42.0); // Creates a value that holds a double with the value 42.
|
||||
///
|
||||
|
@ -306,10 +312,6 @@ public:
|
|||
/// Type::Array, otherwise an empty optional is returned.
|
||||
inline std::optional<sixtyfps::SharedVector<Value>> to_array() const;
|
||||
|
||||
/// Returns a std::optional that contains a model of values if the type of this Value is
|
||||
/// Type::Model, otherwise an empty optional is returned.
|
||||
std::optional<std::shared_ptr<sixtyfps::Model<Value>>> to_model() const;
|
||||
|
||||
/// Returns a std::optional that contains a brush if the type of this Value is
|
||||
/// Type::Brush, otherwise an empty optional is returned.
|
||||
std::optional<sixtyfps::Brush> to_brush() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue