Closed nbigaouette closed 7 years ago
@nbigaouette I've added both f32
and f64
as QMetaTypable
s in https://github.com/White-Oak/qml-rust/commit/eec868f926bdd0ff3a46cf0f6b8e34759730fa9e
Check it out
Nice thanks, will have a look soon.
I still can't use an f32
as a Q_OBJECT!()
property...
I get these errors:
<qml macros>:67:56: 67:61 error: the trait bound `f32: std::convert::From<qml::QVariant>` is not satisfied [E0277]
<qml macros>:67 iter . next ( ) ) ; let property : $ proptype = next . into ( ) ; self . $
^~~~~
src/actioncoil.rs:40:1: 73:4 note: in this expansion of Q_OBJECT! (defined in <qml macros>)
<qml macros>:67:56: 67:61 help: run `rustc --explain E0277` to see a detailed explanation
<qml macros>:67:56: 67:61 help: the following implementations were found:
<qml macros>:67:56: 67:61 help: <f32 as std::convert::From<i8>>
<qml macros>:67:56: 67:61 help: <f32 as std::convert::From<i16>>
<qml macros>:67:56: 67:61 help: <f32 as std::convert::From<u8>>
<qml macros>:67:56: 67:61 help: <f32 as std::convert::From<u16>>
<qml macros>:67:56: 67:61 note: required because of the requirements on the impl of `std::convert::Into<f32>` for `qml::QVariant`
src/actioncoil.rs:82:29: 82:38 error: the trait bound `f32: std::convert::From<&qml::QVariant>` is not satisfied [E0277]
src/actioncoil.rs:82 let inductance_mh = f32::from(self.get_inductance_mh());
^~~~~~~~~
src/actioncoil.rs:82:29: 82:38 help: run `rustc --explain E0277` to see a detailed explanation
src/actioncoil.rs:82:29: 82:38 help: the following implementations were found:
src/actioncoil.rs:82:29: 82:38 help: <f32 as std::convert::From<i8>>
src/actioncoil.rs:82:29: 82:38 help: <f32 as std::convert::From<i16>>
src/actioncoil.rs:82:29: 82:38 help: <f32 as std::convert::From<u8>>
src/actioncoil.rs:82:29: 82:38 help: <f32 as std::convert::From<u16>>
src/actioncoil.rs:82:29: 82:38 note: required by `std::convert::From::from`
Using f32::from()
might not be the best way to do it, but I can use i32::from()
and String::from()
just fine...
@nbigaouette whoops, sorry, it's because I forgot to implement Into for QVariant and f32, f64. I'll get it done today/
According to the doc, only
String
andi32
implement QMetaTypable. This means one can't pass a floating point value from/to QML.Could an impl be added for either f32 or f64?
Thanks!