Class QtQuickViewContent

java.lang.Object
org.qtproject.qt.android.QtQuickViewContent

public abstract class QtQuickViewContent extends Object
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 Details

    • QtQuickViewContent

      public QtQuickViewContent()
  • Method Details

    • getLibraryName

      public abstract String getLibraryName()
      Implement this to return the library name that this component belongs to.
    • getModuleName

      public abstract String getModuleName()
      Implement this to return the module name that this component belongs to.
    • getFilePath

      public abstract String getFilePath()
      Implement this to return the qrc (Qt Resource) path of this QML component.
    • setStatusChangeListener

      public void setStatusChangeListener(QtQmlStatusChangeListener listener)
      Sets a StatusChangeListener to listen to status changes.
      Parameters:
      listener - an instance of a StatusChangeListener interface
    • getQuickView

      protected QtQuickView 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

      protected void attachView(QtQuickView view)
      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

      protected HashMap<String,Object> attributes()
      Implement this to return more information about the QML Component. Default implementation returns an empty HashMap.
    • setProperty

      protected 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. The supported types are Integer, Double, Float, Boolean and String. 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 of
      value - the value to set the property to QML's int, double/float, bool or string
      See Also:
    • getProperty

      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. The supported types are Integer, Double, Float, Boolean and String. 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 than QtQmlStatus.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 signal
      argType - the Class type of the signal argument
      listener - 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

      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.
      Parameters:
      signalName - the name of the root object signal
      argTypes - the Class types of the signal arguments
      listener - 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 from QtQuickView.connectSignalListener(String, Class, QtSignalListener) or QtQuickView.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.