11.07.2018, 12:29, "René J.V. Bertin" <rjvber...@gmail.com>:
> Hi,
>
> I'm tinkering with using a Qt plugin that expects a QApplication in a 
> QGuiApplication (specifically, a QML application using QGuiApplication).
> I'm not doing anything that causes a straight crash (or haven't run into that 
> one fatal instruction yet), but I do wonder:
>
> is it in any way possible to promote a QGuiApplication instance to a 
> QApplication? Somewhat unexpectedly, `dynamic_cast<QApplication*>(qApp)` 
> behaves as `static_cast` or `const_cast` in this case (= it returns qApp). Or 
> it returns a nullptr in
>
> QGuiApplication app(argc, argv);
> QApplication *gapp = dynamic_cast<QApplication*>(&app);
>
> which is probably what you'd expect.
>
> Still, with QApplication inheriting QGuiApplication one could think that the 
> former does some initialisation the latter lacks and that it should be 
> possible to perform those steps at a later stade. Is it?

If application object is created as QGuiApplication, you obviously cannot cast 
it to QApplication.

If you want to do something only when application object is created as 
QApplication (or its subclass), use qApp pointer


-- 
Regards,
Konstantin

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to