44// SPDX-License-Identifier: MIT OR Apache-2.0
55
66use core:: pin:: Pin ;
7- use cxx_qt_lib:: { QByteArray , QFont , QString , QStringList , QVector } ;
7+ use cxx_qt:: Upcast ;
8+ use cxx_qt_lib:: { QByteArray , QFont , QGuiApplication , QString , QStringList , QVector } ;
9+ use std:: ops:: Deref ;
810
911#[ cxx:: bridge]
1012mod ffi {
@@ -24,6 +26,22 @@ mod ffi {
2426 type QApplication ;
2527 }
2628
29+ #[ namespace = "rust::cxxqt1" ]
30+ unsafe extern "C++" {
31+ include ! ( "cxx-qt/casting.h" ) ;
32+
33+ include ! ( "cxx-qt-lib/qguiapplication.h" ) ;
34+ type QGuiApplication = cxx_qt_lib:: QGuiApplication ;
35+
36+ #[ doc( hidden) ]
37+ #[ rust_name = "upcast_qapplication" ]
38+ unsafe fn upcastPtr ( thiz : * const QApplication ) -> * const QGuiApplication ;
39+
40+ #[ doc( hidden) ]
41+ #[ rust_name = "downcast_qapplication" ]
42+ unsafe fn downcastPtrStatic ( base : * const QGuiApplication ) -> * const QApplication ;
43+ }
44+
2745 #[ namespace = "rust::cxxqtlib1" ]
2846 unsafe extern "C++" {
2947 #[ doc( hidden) ]
@@ -93,6 +111,24 @@ mod ffi {
93111
94112pub use ffi:: QApplication ;
95113
114+ impl Upcast < QGuiApplication > for QApplication {
115+ unsafe fn upcast_ptr ( this : * const Self ) -> * const QGuiApplication {
116+ ffi:: upcast_qapplication ( this)
117+ }
118+
119+ unsafe fn from_base_ptr ( base : * const QGuiApplication ) -> * const Self {
120+ ffi:: downcast_qapplication ( base)
121+ }
122+ }
123+
124+ impl Deref for QApplication {
125+ type Target = QGuiApplication ;
126+
127+ fn deref ( & self ) -> & Self :: Target {
128+ self . upcast ( )
129+ }
130+ }
131+
96132impl QApplication {
97133 /// Prepends path to the beginning of the library path list,
98134 /// ensuring that it is searched for libraries first.
0 commit comments