@@ -53,10 +53,6 @@ pub mod ffi {
53
53
}
54
54
55
55
unsafe extern "RustQt" {
56
- /// Initialise the QObject, creating a connection from one signal to another
57
- #[ qinvokable]
58
- fn initialise ( self : Pin < & mut qobject:: OuterObject > ) ;
59
-
60
56
/// Print the count of the given inner QObject
61
57
//
62
58
// This method needs to be unsafe otherwise clippy complains that the
@@ -68,30 +64,15 @@ pub mod ffi {
68
64
#[ qinvokable]
69
65
fn reset ( self : Pin < & mut qobject:: OuterObject > ) ;
70
66
}
67
+
68
+ impl cxx_qt:: Constructor < ( ) > for qobject:: OuterObject { }
71
69
}
72
70
73
71
use core:: pin:: Pin ;
74
72
75
73
// TODO: this will change to qobject::OuterObject once
76
74
// https://github.com/KDAB/cxx-qt/issues/559 is done
77
75
impl ffi:: OuterObjectQt {
78
- /// Initialise the QObject, creating a connection from one signal to another
79
- fn initialise ( self : Pin < & mut Self > ) {
80
- // Example of connecting a signal from one QObject to another QObject
81
- // this causes OuterObject::Called to trigger InnerObject::Called
82
- self . on_called ( |qobject, obj| {
83
- // We need to convert the *mut T to a Pin<&mut T> so that we can reach the methods
84
- if let Some ( inner) = unsafe { qobject. inner ( ) . as_mut ( ) } {
85
- let pinned_inner = unsafe { Pin :: new_unchecked ( inner) } ;
86
- // Now pinned inner can be used as normal
87
- unsafe {
88
- pinned_inner. called ( obj) ;
89
- }
90
- }
91
- } )
92
- . release ( ) ;
93
- }
94
-
95
76
/// Print the count of the given inner QObject
96
77
//
97
78
// This method needs to be unsafe otherwise clippy complains that the
@@ -120,4 +101,42 @@ impl ffi::OuterObjectQt {
120
101
unsafe { self . called ( inner) } ;
121
102
}
122
103
}
104
+
105
+ impl cxx_qt:: Constructor < ( ) > for qobject:: OuterObject {
106
+ type InitializeArguments = ( ) ;
107
+ type NewArguments = ( ) ;
108
+ type BaseArguments = ( ) ;
109
+
110
+ fn route_arguments (
111
+ _: ( ) ,
112
+ ) -> (
113
+ Self :: NewArguments ,
114
+ Self :: BaseArguments ,
115
+ Self :: InitializeArguments ,
116
+ ) {
117
+ ( ( ) , ( ) , ( ) )
118
+ }
119
+
120
+ fn new ( _: Self :: NewArguments ) -> <Self as cxx_qt:: CxxQtType >:: Rust {
121
+ Default :: default ( )
122
+ }
123
+
124
+ /// Initialise the QObject, creating a connection from one signal to another
125
+ fn initialize ( self : core:: pin:: Pin < & mut Self > , _: Self :: InitializeArguments ) {
126
+ // Example of connecting a signal from one QObject to another QObject
127
+ // this causes OuterObject::Called to trigger InnerObject::Called
128
+ self . on_called ( |qobject, obj| {
129
+ // We need to convert the *mut T to a Pin<&mut T> so that we can reach the methods
130
+ if let Some ( inner) = unsafe { qobject. inner ( ) . as_mut ( ) } {
131
+ let pinned_inner = unsafe { Pin :: new_unchecked ( inner) } ;
132
+ // Now pinned inner can be used as normal
133
+ unsafe {
134
+ pinned_inner. called ( obj) ;
135
+ }
136
+ }
137
+ } )
138
+ . release ( ) ;
139
+ }
140
+ }
141
+
123
142
// ANCHOR_END: book_macro_code
0 commit comments