Class QtQuickViewContent
java.lang.Object
org.qtproject.qt.android.QtQuickViewContent
The QtQuickViewContent represents a QML component that can be loaded by a QtQuickView instance.
This abstract class should be extended to be used by a QtQuickView. It provides QtQuickView with
essential information to load the QML component it represents.
It also offers convenient methods for seamless interaction with the QtQuickView that loads it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
attachView
(QtQuickView view) Attaches this to a QtQuickView instance.Implement this to return more information about the QML Component.protected int
connectSignalListener
(String signalName, Class<?>[] argTypes, Object listener) Connects a SignalListener to a signal of the QML component if it has already been attached and loaded by a QtQuickView instance.protected <T> int
connectSignalListener
(String signalName, Class<T> argType, org.qtproject.qt.android.QtSignalListener<T> listener) Connects a SignalListener to a signal of the QML component if it has already been attached and loaded by a QtQuickView instance.protected void
Detaches this from the QtQuickView to which it has previously been attached.boolean
disconnectSignalListener
(int signalListenerId) Disconnects a SignalListener with a given id obtained fromQtQuickView.connectSignalListener(String, Class, QtSignalListener)
orQtQuickView.connectSignalListener(String, Class[], Object)
call, from listening to a signal.abstract String
Implement this to return the qrc (Qt Resource) path of this QML component.abstract String
Implement this to return the library name that this component belongs to.abstract String
Implement this to return the module name that this component belongs to.protected <T> T
getProperty
(String propertyName) Gets the value of an existing property of the QML component if it has already been attached and loaded by a QtQuickView instance.protected QtQuickView
Gets the QtQuickView instance that has loaded this component.protected boolean
Checks if this is currently attached to a QtQuickView instanceprotected void
setProperty
(String propertyName, Object value) Sets the value of an existing property on the QML component if it has already been attached and loaded by a QtQuickView instance.void
Sets a StatusChangeListener to listen to status changes.
-
Constructor Details
-
QtQuickViewContent
public QtQuickViewContent()
-
-
Method Details
-
getLibraryName
Implement this to return the library name that this component belongs to. -
getModuleName
Implement this to return the module name that this component belongs to. -
getFilePath
Implement this to return the qrc (Qt Resource) path of this QML component. -
setStatusChangeListener
Sets a StatusChangeListener to listen to status changes.- Parameters:
listener
- an instance of a StatusChangeListener interface
-
getQuickView
Gets the QtQuickView instance that has loaded this component.- Returns:
- Returns an instance of QtQuickView or null if this component is not loaded by any QtQuickView.
-
isViewAttached
protected boolean isViewAttached()Checks if this is currently attached to a QtQuickView instance- Returns:
- Returns true if this is attached to a QtQuickView instance, otherwise, returns false.
-
attachView
Attaches this to a QtQuickView instance. -
detachView
protected void detachView()Detaches this from the QtQuickView to which it has previously been attached. A call to this method will disconnect all signal listeners that have been connected before. -
attributes
-
setProperty
Sets the value of an existing property on the QML component if it has already been attached and loaded by a QtQuickView instance. The supported types areInteger
,Double
,Float
,Boolean
andString
. These types get converted to their corresponding QML types int, double/float, bool, and string. This function does not add properties to the QML root object if they do not exist but prints a warning.- Parameters:
propertyName
- the name of the existing QML property to set the value ofvalue
- the value to set the property to QML's int, double/float, bool or string- See Also:
-
getProperty
Gets the value of an existing property of the QML component if it has already been attached and loaded by a QtQuickView instance. The supported types areInteger
,Double
,Float
,Boolean
andString
. These types get converted to their corresponding QML types int, double/float, bool and string. If the property does not exist or the status of the QML component is anything other thanQtQmlStatus.READY
, this function will return null.- Parameters:
propertyName
- the name of the existing root object property- Throws:
ClassCastException
- if the returned type cannot be cast to the requested type.- See Also:
-
connectSignalListener
protected <T> int connectSignalListener(String signalName, Class<T> argType, org.qtproject.qt.android.QtSignalListener<T> listener) Connects a SignalListener to a signal of the QML component if it has already been attached and loaded by a QtQuickView instance.- Parameters:
signalName
- the name of the root object signalargType
- the Class type of the signal argumentlistener
- an instance of the QtSignalListener interface- Returns:
- a connection ID between signal and listener or the existing connection ID if there is an existing connection between the same signal and listener. Return a negative value if the signal does not exist on the QML root object.
-
connectSignalListener
Connects a SignalListener to a signal of the QML component if it has already been attached and loaded by a QtQuickView instance.- Parameters:
signalName
- the name of the root object signalargTypes
- the Class types of the signal argumentslistener
- an instance of the QtSignalListener interface- Returns:
- a connection ID between signal and listener or the existing connection ID if there is an existing connection between the same signal and listener. Return a negative value if the signal does not exist on the QML root object.
-
disconnectSignalListener
public boolean disconnectSignalListener(int signalListenerId) Disconnects a SignalListener with a given id obtained fromQtQuickView.connectSignalListener(String, Class, QtSignalListener)
orQtQuickView.connectSignalListener(String, Class[], Object)
call, from listening to a signal.- Parameters:
signalListenerId
- the connection id- Returns:
- Returns true if the connection id is valid and has been successfully removed, otherwise returns false.
-