Skip to content

Commit f352c04

Browse files
Add Transitive casting and testing code
1 parent a02ef71 commit f352c04

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

crates/cxx-qt-gen/src/generator/rust/fragment.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,11 @@ impl GeneratedRustFragment {
8383
#upcast_fn_qualified(this)
8484
}
8585

86-
unsafe fn from_base_ptr(base: *const #base_qualified) -> *const Self {
87-
#downcast_fn_qualified(base)
88-
}
86+
unsafe fn from_base_ptr(base: *const #base_qualified) -> *const Self {
87+
#downcast_fn_qualified(base)
8988
}
90-
},
91-
// Add back once we figure out the bug with QObject, for automatic transitive casts
92-
// parse_quote! {
93-
// unsafe impl ::cxx_qt::MainCast for #struct_name {
94-
// type Base = #base_qualified;
95-
// }
96-
// }
97-
],
89+
}
90+
}],
9891
})
9992
}
10093

crates/cxx-qt/src/casting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ unsafe impl<T> Upcast<T> for T {
127127
self
128128
}
129129
}
130+
130131
/// Implements transitive casting in a chain for a type and all its ancestors
131132
///
132133
/// Suppose you have 3 types, A, B and C where A -> B and B -> C casting relationships exist,

examples/qml_minimal/qml/main.qml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ ApplicationWindow {
2828
string: qsTr("My String with my number: %1").arg(myObject.number)
2929
}
3030

31-
A {
32-
id: a
33-
number: 10
34-
}
35-
3631
Column {
3732
anchors.fill: parent
3833
anchors.margins: 10
@@ -60,12 +55,6 @@ ApplicationWindow {
6055
onClicked: myObject.sayHi(myObject.string, myObject.number)
6156
}
6257

63-
Button {
64-
text: qsTr("Test A")
65-
66-
onClicked: a.test()
67-
}
68-
6958
Button {
7059
text: qsTr("Quit")
7160

0 commit comments

Comments
 (0)