Class QtRaaSApplication
QtRaaSApplication class serves as the Java-side entry point
for embedding a Qt-based Rendering as a Service (RaaS) application
into an Android environment.
It is responsible for:
- Loading the required Qt libraries and native components.
- Creating a service adapter when running outside of an Android Service context.
- Forwarding Android
SurfaceandMotionEventevents to the Qt runtime through JNI bindings.
This class is typically instantiated from an Android Service
to initialize and manage the Qt runtime environment and its surface-based rendering
pipeline.
-
Constructor Summary
ConstructorsConstructorDescriptionQtRaaSApplication(android.content.Context context) Constructs aQtRaaSApplicationinstance using the given context, and loads the default Qt main library.QtRaaSApplication(android.content.Context context, String mainLibraryName) Constructs a newQtRaaSApplicationinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidsendTouchEvent(android.view.MotionEvent event, String itemId) Forwards aMotionEventfrom Android to the corresponding Qt Quick item identified byitemId.voidsetSurface(android.view.Surface surface, String itemId) Sets a new AndroidSurfaceto be associated with a Qt Quick item identified by the givenitemId.voidunsetSurface(String itemId) Unsets the surface that was previously associated with the Qt Quick item identified by the givenitemId.
-
Constructor Details
-
QtRaaSApplication
Constructs a newQtRaaSApplicationinstance.This constructor initializes and loads the Qt runtime environment using the provided
Contextand the name of the main Qt library.- Parameters:
context- the Android contextmainLibraryName- the main Qt library name (without prefix/suffix).
-
QtRaaSApplication
public QtRaaSApplication(android.content.Context context) Constructs aQtRaaSApplicationinstance using the given context, and loads the default Qt main library.- Parameters:
context- the Android context or service
-
-
Method Details
-
setSurface
Sets a new AndroidSurfaceto be associated with a Qt Quick item identified by the givenitemId.This native method forwards the provided surface handle to the Qt side, where it is mapped to the corresponding item and used for rendering through the
QAndroidSurfaceRenderEngine.- Parameters:
surface- the Android surface object to associateitemId- the id of the Qt Quick itemNotes:
- This method is implemented in native (C++) code.
- If
itemIdis invalid, this method will fail with a warning. - Passing an invalid
surfaceresults in undefined behavior. - Passing
nullas thesurfaceis equivalent to callingunsetSurface(String).
- See Also:
-
sendTouchEvent
Forwards aMotionEventfrom Android to the corresponding Qt Quick item identified byitemId.This method retrieves and handles touch input forwarding to the Qt side for the specified item.
- Parameters:
event- the Android touch motion event to senditemId- the id of the Qt Quick item that receives the event
-
unsetSurface
Unsets the surface that was previously associated with the Qt Quick item identified by the givenitemId.This method forwards a
nullsurface to the Qt side to stop rendering the item on the surface that was previously associated with it.- Parameters:
itemId- the id of the Qt Quick itemNote: It is crucial to call this method when the surface is about to be destroyed.
-