GCF LOGO VCL LOGO

Base-class for GCF::QmlApplication. More...

#include <GCF3/QmlApplication>

Public Member Functions

void setQmlEngine (QQmlEngine *engine)
 
QQmlEngine * qmlEngine () const
 
- Public Member Functions inherited from GCF::ApplicationServices
QDateTime launchTimestamp () const
 
ObjectTreeobjectTree () const
 
QObject * findObject (const QString &path) const
 
void loadComponent (Component *component)
 
void unloadComponent (Component *component)
 
QObjectList components () const
 
void activateComponent (Component *component)
 
void deactivateComponent (Component *component)
 
bool isLoaded (const Component *component) const
 
bool isActive (const Component *component) const
 
void unloadAllComponents ()
 
ComponentinstantiateComponent (const QString &library)
 
ComponentloadComponent (const QString &library)
 
ComponentloadComponent (const QString &library, const QList< QPair< QByteArray, QVariant > > &properties)
 
QList< Component * > loadComponents (const QStringList &libraries)
 
QVariantMap argumentsMap () const
 
void processArguments (const QStringList &additionalArgs=QStringList())
 
GCF::Result invokeMethod (const QString &path, const QString &method, const QVariantList &args, bool secureCall=true) const
 This method can be used to invoke a named method in an object. More...
 
GCF::JobListModeljobs () const
 
QString translate (const QString &string) const
 

Static Public Member Functions

static QmlApplicationServicesinstance ()
 
- Static Public Member Functions inherited from GCF::ApplicationServices
static GCF::Result invokeMethod (QObject *object, const QString &method, const QVariantList &args, bool secureCall=true)
 This method can be used to invoke a named method in an object. More...
 
static GCF::Result invokeMethod (QObject *object, const QMetaMethod &method, const QVariantList &args, bool secureCall=true)
 This method can be used to invoke a named method in an object. More...
 

Protected Member Functions

 QmlApplicationServices ()
 
 ~QmlApplicationServices ()
 
virtual void initQmlEngine (QQmlEngine *)
 
- Protected Member Functions inherited from GCF::ApplicationServices
 ApplicationServices ()
 
virtual ~ApplicationServices ()
 

Detailed Description

This class extends GCF::ApplicationServices by offering certain Qml specific application services in addition to what the base class offers. Its subclass GCF::QmlApplication should be instantiated for writing QML+GCF applications. Whenever an instance of GCF::QmlApplication is created, you must call the setQmlEngine() method to set the application engine that will be used by your QML application.

You will never have to use this class directly, because in most cases you will create an instance of GCF::QmlApplication and use that. There is one exception though: read documentation for initQmlEngine() to know more.

Note
This class is available only if GCF is compiled and linked against Qt 5.

Constructor & Destructor Documentation

GCF::QmlApplicationServices::QmlApplicationServices ( )
protected

Constructor

GCF::QmlApplicationServices::~QmlApplicationServices ( )
protected

Destructor

Member Function Documentation

GCF::QmlApplicationServices * GCF::QmlApplicationServices::instance ( )
static

This function returns pointer to the only instance of GCF::QmlApplicationServices in the application. The function returns NULL if no such instance was created.

void GCF::QmlApplicationServices::setQmlEngine ( QQmlEngine *  engine)

Using this function you can set the QML engine for use with your GCF application. This function has to be called before any QML code is loaded and evaluated by the engine.

Parameters
enginepointer to a QQmlEngine that needs to be set as GCF's Qml engine

Example:

int main(int argc, char **argv)
{
GCF::QmlApplication a(argc, argv);
QQuickView qmlView;
a.setQmlEngine(qmlView.engine());
qmlView.setSource(....);
qmlView.show();
return a.exec();
}

This function sets two context-properties on the engine's root-context.

  • gApp - references the GCF application object
  • gcf - references an internal GCF object that offers the following methods
    • findObject(string) : returns an object at the specified path
    • findImplementation(string) : returns an object that implements the specified class/interface
    • findImplementations(string) : returns all objects that implement the specified class/interface
    • addQmlItem(string,object) : adds a QML item to the object tree with the first parameter as name. Once added, the item will be exposed as "Application.{name}"
    • removeQmlItem(string) : removes a QML item, whose name is specified in the parameter, from the object tree
    At the end the initQmlEngine() method is called. You can subclass from GCF::QmlApplicationServices or GCF::QmlApplication and reimplement this method to customize further initialization of the engine.
Note
this function can be called only once. Once the engine is set, further calls to this function become a no-op.
QQmlEngine * GCF::QmlApplicationServices::qmlEngine ( ) const

Returns pointer to the QQmlEngine that was set using the setQmlEngine() method. NULL pointer if no engine was set.

void GCF::QmlApplicationServices::initQmlEngine ( QQmlEngine *  )
protectedvirtual

You can reimplement this function to customize the initialization of the QQmlEngine passed as paramete to this function. This function is called from setQmlEngine(). By the time this function is called, the gcf and gApp context properties have already been set.

The default implementation does nothing.