White-Oak / qml-rust

QML (Qt Quick) bindings for Rust language
MIT License
205 stars 18 forks source link

Array as parameter of signal #11

Closed vchekan closed 8 years ago

vchekan commented 8 years ago

Is it possible to have an array as parameter of a signal? I want to pass Vec but this declaration fails:

Q_OBJECT! {
    pub Logic as QLogic {
    signals:
        fn gains(gainList: QVariant);

with error:

src/main.rs:45:36: 76:54 error: no associated item named `metatype` found for type `qml::qvariant::QVariant` in the current scope
(internal compiler error: unprintable span)
src/main.rs:41:1: 50:2 note: in this expansion of Q_OBJECT! (defined in <qml macros>)

Which types can be signal parameters?

rustonaut commented 8 years ago

For some reasons it is only implemented for:

i32, f32, f64, i32, String

I have no idea why it is not implemented for:

i64, bool

And I don't know jet enough about the inner workings of Qt to say anything about "generall" QVariant, QObject and Lists of above's type.

White-Oak commented 8 years ago

Yes, it should be also implement for other types as well. Sorry for this and the delay

White-Oak commented 8 years ago

@vchekan thanks for the issue, and sorry for quite the delay! It is now possible to use arrays as QObject properties, as you can see in this example.

More information is available in docs: QVariantList, qvarlist! (see qvarlists example). If there is something left unclear, please ask!