Support using ign-gui QML components in fully custom downstream application
#320 opened on Nov 24, 2021
Repository metrics
- Stars
- (103 stars)
- PR merge metrics
- (PR metrics pending)
Description
Desired behavior
I would like to incorporate ign-gui and also ign-rviz QML components in an existing Qt Quick application. The existing application sets up a QGuiApplication already and needs to do some different things than what ignition::gui::Aplication does for the following:
- Loads application specific QML into the
QQmlApplicationEngine(see https://doc.qt.io/qt-5/qqmlapplicationengine.html#load-1). - Sets up a custom
SIGINTsignal handler - Sets up custom Qt message handler
Implementation suggestion
In order to use ign-gui QML components in a downstream application, I would like to suggest a couple of changes.
- The method
ignition::gui::App()returns a pointer of typeignition::gui::Application. Can an abstract base class be defined and thenignition::gui::App()returns the base class? ThenApplicationwould be changed to inherit from the base class. - The
Applicationclass performs a lot of plugin loading logic. Could the majority of this logic be extracted to a helper class that could also be used downstream? Ideally, theApplicationclass would then only be specific to setting up and interacting withignition::gui::MainWindowand other "top level" things like signal handlers and logging.- Note that the method
ignition::gui::Application::AddPluginsToWindowis specific to proably too specific toigntion::gui::MainWindowto be extracted, but maybe it could be broken down some with common functionality extracted.
- Note that the method
Alternatives considered
I could subclass the ignition::gui::Application class as-is and override the constructor and other methods. I would have to work around the issues described here and I am not sure how feasible this solution is without testing it.
Additional context
N/A