File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,13 @@ impl QVariant {
93
93
} )
94
94
}
95
95
96
+ /// Return a `null` QVariant, in contrast to `default()` which returns an `undefined` QVariant.
97
+ pub fn null ( ) -> QVariant {
98
+ cpp ! ( unsafe [ ] -> QVariant as "QVariant" {
99
+ return QJsonValue ( ) . toVariant( ) ;
100
+ } )
101
+ }
102
+
96
103
// FIXME: do more wrappers
97
104
}
98
105
@@ -293,4 +300,15 @@ mod tests {
293
300
assert_eq ! ( qv. to_int( ) , 313 ) ;
294
301
assert_eq ! ( format!( "{:?}" , qv) , "QVariant(int: \" 313\" )" ) ;
295
302
}
303
+
304
+ #[ test]
305
+ fn qvariant_null ( ) {
306
+ let qv_undefined = QVariant :: default ( ) ;
307
+ assert ! ( qv_undefined. is_null( ) ) ;
308
+ assert ! ( !qv_undefined. is_valid( ) ) ;
309
+
310
+ let qv_null = QVariant :: null ( ) ;
311
+ assert ! ( qv_null. is_null( ) ) ;
312
+ assert ! ( qv_null. is_valid( ) ) ;
313
+ }
296
314
}
You can’t perform that action at this time.
0 commit comments