ArnLib  4.0.x
Active Registry Network
ArnQml Class Reference

ARN QML. More...

#include <ArnQml.hpp>

Inheritance diagram for ArnQml:
Collaboration diagram for ArnQml:

Classes

struct  UseFlags
 

Static Public Member Functions

static void setup (QML_ENGINE *qmlEngine, UseFlags flags=UseFlags::ArnLib)
 Add ArnLib support to a Qml instance. More...
 
static ArnQmlinstance ()
 
static QString arnRootPath ()
 Gives current ARN root path for all qml instances. More...
 
static void setArnRootPath (const QString &path)
 Change ARN root path for all qml instances. More...
 

Detailed Description

ARN QML.

Note
This class must be partly thread-safe

This class is the central point for ArnQml. It's a singleton that is setup in the application. ArnQml can be used for creating GUI-applications in Qml that has integrated access to the ARN objects and some of the ArnLib funtionality.

For information about available ArnLib components in Qml see:

QmlType See
Arn ArnInterface
ArnItem ArnItemQml
ArnMonitor ArnMonitorQml
ArnSapi ArnSapiQml
XStringMap XStringMapQml

If the Qml code must run in both Quick1 (Qt4) and Quick2 (Qt5), following apply: Only Quick1 code will be able to run in both environments. When this code is run in Quick2 its "import QtQuick 1" will be changed internally to "import QtQuick 2". "arn" is now an instantiation of ArnInterface and "Arn" is the type. In qml "arn.quickTypeRun" will give a 1 when running in a QtQuick1 environment and a 2 for QtQuick2.

When the Qml code only is to be run in Quick2 it should use "import QtQuick 2". In this case "Arn" will be a singleton instantiation of ArnInterface. "arn" is then not needed.

ArnBrowser is using this class to run Qml applications in an opaque style, i.e. without specific application support. This resembles somewhat a web browser running a web application.

Note that you must not use any empty folders in QUrl for an ARN path. Example: path "//Qml/test.qml" can be set to the equal path "/@/Qml/test.qml". Also this conversion can be made by Arn::convertPath("//Qml/test.qml", Arn::NameF()).

Example usage

// In c++
//
QQuickView* view = new QQuickView;
QString qmlPathInArn = "//Qml/test.qml"
QUrl url;
url.setScheme("arn");
url.setPath( Arn::convertPath( qmlPathInArn, Arn::NameF()));
view->setSource( url);
view->show();
connect( engine(), SIGNAL(quit()), this, SLOT(onClose()));
connect( view, SIGNAL(closing(QQuickCloseEvent*)), this, SLOT(onClose()));
// In Qml
//
import QtQuick 2.0
import ArnLib 1.0
Rectangle {
width: 370; height: 400
clientId: "std"
monitorPath: "//Test/List/"
onArnChildFound: console.log("Found list item: " + path);
}
Image {
anchors.top: parent.top; anchors.right: parent.right;
source: "arn:///@/Test/Data/pic.png"
}
ArnItem {id: arnElUpdClock; path: "//El/UpdClock/value"}
Item {
id: sapiTest
ArnSapi {pipePath: "//Test/pipe"}
// Provider API
signal pv_readFileTest( string fileName)
// Requester API
signal rq_test2( string par1)
function rq_test( p1) {
console.log("rq_test: p1=" + p1);
}
Component.onCompleted: {
sapiTest.rq_test2.connect( info.setTestMsg);
sapiTest.pv_readFileTest("myfile");
}
}
Rectangle {
id: info
property string testMsg: ""
anchors.bottom: parent.bottom; anchors.left: parent.left; anchors.right: parent.right
height: 80
Column {
anchors.fill: parent;
Text {text: "El updClock: " + arnElUpdClock.intNum}
Text {text: "Msg: " + info.testMsg}
Text {text: Arn.info} // ArnLib version info
}
function setTestMsg( msg) {
info.testMsg = msg;
}
}
}

Definition at line 183 of file ArnQml.hpp.

Member Function Documentation

◆ arnRootPath()

QString ArnQml::arnRootPath ( )
static

Gives current ARN root path for all qml instances.

Returns
the root path
See also
setArnRootPath

Definition at line 60 of file ArnQml.cpp.

◆ instance()

ArnQml & ArnQml::instance ( )
static

Definition at line 119 of file ArnQml.cpp.

◆ setArnRootPath()

void ArnQml::setArnRootPath ( const QString &  path)
static

Change ARN root path for all qml instances.

This is set once in the application and must be set before any qml instances are setup.

Example: setArnRootPath("/@myHost/"); will map a path "/Test/value" in Qml to an ARN object at path "/@myHost/Test/value".

Parameters
[in]pathis the root path
See also
arnRootPath

Definition at line 66 of file ArnQml.cpp.

◆ setup()

void ArnQml::setup ( QML_ENGINE qmlEngine,
ArnQml::UseFlags  flags = UseFlags::ArnLib 
)
static

Add ArnLib support to a Qml instance.

ArnLib module is always included.

Parameters
[in]qmlEngineis the qml instance engine
[in]flagsgives the modules to include

Definition at line 82 of file ArnQml.cpp.


The documentation for this class was generated from the following files: