LiveNodeEngine Class

The LiveNodeEngine class instantiates QML components in cooperation with LiveHubEngine. More...

Header: #include <LiveNodeEngine>
Inherits: QObject

Public Types

enum WorkspaceOption { NoWorkspaceOption, LoadDummyData, AllowUpdates, UpdatesAsOverlay }
flags WorkspaceOptions

Public Functions

LiveNodeEngine(QObject *parent = 0)
virtual ~LiveNodeEngine()
LiveDocument activeDocument() const
ContentAdapterInterface *activePlugin() const
QQuickWindow *activeWindow() const
QQuickView *fallbackView() const
QString pluginPath() const
QQmlEngine *qmlEngine() const
int rotation() const
void setFallbackView(QQuickView *fallbackView)
void setPluginPath(const QString &path)
void setQmlEngine(QQmlEngine *qmlEngine)
void setWorkspace(const QString &path, LiveNodeEngine::WorkspaceOptions options = NoWorkspaceOption)
void usePreloadedDocument(const LiveDocument &document, QObject *object, QQuickWindow *window, const QList<QQmlError> &errors)
void usePreloadedDocument(const QString &document, QQuickWindow *window, const QList<QQmlError> &errors)
QString workspace() const
int xOffset() const
int yOffset() const

Public Slots

void delayReload()
void loadDocument(const LiveDocument &document)
virtual void reloadDocument()
void setRotation(int rotation)
void setXOffset(int offset)
void setYOffset(int offset)
void updateDocument(const LiveDocument &document, const QByteArray &content)


void activeDocumentChanged(const LiveDocument &document)
void activeWindowChanged(QQuickWindow *window)
void clearLog()
void documentLoaded()
void logErrors(const QList<QQmlError> &errors)
void logIgnoreMessages(bool on)
void workspaceChanged(const QString &workspace)

Protected Functions

virtual void initPlugins()

Detailed Description

LiveNodeEngine provides ways to reload QML documents based incoming requests from a hub. A hub can be connected via a RemotePublisher/RemoteReceiver pair.

The primary use case is to allow loading of QML components instantiating QQuickWindow, i.e., inheriting QML Window. A fallbackView can be set in order to support also QML Item based components.

In Addition to showing QML files the LiveNodeEngine can be extended by plugins to show any other filetype. One need to set the Plugin path to the right destination and the LiveNodeEngine will load all the plugins it finds there.

See also Custom Runtime and ContentPlugin Example.

Member Type Documentation

enum LiveNodeEngine::WorkspaceOption
flags LiveNodeEngine::WorkspaceOptions

This enum type controls optional workspace related features:

LiveNodeEngine::NoWorkspaceOption0x0No optional feature is enabled.
LiveNodeEngine::LoadDummyData0x1Enables loading of dummy QML data - QML documents located in the "dummydata" subdirectory of the workspace directory.
LiveNodeEngine::AllowUpdates0x2Enables receiving updates to workspace documents.
LiveNodeEngine::UpdatesAsOverlay0x4With this option enabled, updates can be received even if workspace is read only. Updates will be stored in a writable overlay stacked over the original workspace with the help of QQmlAbstractUrlInterceptor. Requires AllowUpdates.

The WorkspaceOptions type is a typedef for QFlags<WorkspaceOption>. It stores an OR combination of WorkspaceOption values.

See also QmlLive Runtime.

Member Function Documentation

LiveNodeEngine::LiveNodeEngine(QObject *parent = 0)

Standard constructor using parent as parent

[signal] void LiveNodeEngine::activeDocumentChanged(const LiveDocument &document)

The document document was loaded with loadDocument() and is now the activeDocument(). This signal is only emitted when the new document differs from the previously loaded one.

See also documentLoaded().

[signal] void LiveNodeEngine::activeWindowChanged(QQuickWindow *window)

The signal is emitted when the activeWindow has changed by changing or reloading the document. window is the newly activated window.

[signal] void LiveNodeEngine::clearLog()

Requested to clear the log

[slot] void LiveNodeEngine::delayReload()

Starts a timer to reload the view with a delay.

A delay reload is important to avoid constant reloads, while many changes appear.

[signal] void LiveNodeEngine::documentLoaded()

The signal is emitted when the document has finished loading.

[slot] void LiveNodeEngine::loadDocument(const LiveDocument &document)

Loads or reloads the given document onto the QML view. Clears any caches.

The activeDocumentChanged() signal is emitted when this results in change of the activeDocument().

See also documentLoaded().

[signal] void LiveNodeEngine::logErrors(const QList<QQmlError> &errors)

Log the Errors errors

[signal] void LiveNodeEngine::logIgnoreMessages(bool on)

Requsted to ignore the Messages when on is true

[virtual slot] void LiveNodeEngine::reloadDocument()

Reloads the active QML document.

Emits documentLoaded() when finished.

If fallbackView is set, its source will be cleared, whether the view was previously used or not.

[slot] void LiveNodeEngine::setRotation(int rotation)

Sets the rotation rotation of window around the center

See also rotation().

[slot] void LiveNodeEngine::setXOffset(int offset)

Sets the x-offset offset of window

See also xOffset().

[slot] void LiveNodeEngine::setYOffset(int offset)

Sets the y-offset offset of window

See also yOffset().

[slot] void LiveNodeEngine::updateDocument(const LiveDocument &document, const QByteArray &content)

Updates content of the given workspace document when enabled.

The behavior of this function is controlled by WorkspaceOptions passed to setWorkspace().

[signal] void LiveNodeEngine::workspaceChanged(const QString &workspace)

This signal is emitted after workspace is changed with setWorkspace(). workspace is the new workspace path.

See also workspace().

[virtual] LiveNodeEngine::~LiveNodeEngine()


LiveDocument LiveNodeEngine::activeDocument() const

Returns the current active document.

ContentAdapterInterface *LiveNodeEngine::activePlugin() const

Returns the active content adapter plugin

QQuickWindow *LiveNodeEngine::activeWindow() const

Returns the current active window.

See also activeWindowChanged().

QQuickView *LiveNodeEngine::fallbackView() const

The QQuickView for displaying QML Item based components, i.e., those not creating own windows.

See also setFallbackView().

[virtual protected] void LiveNodeEngine::initPlugins()

Loads all plugins found in the Pluginpath

QString LiveNodeEngine::pluginPath() const

Returns the current pluginPath

See also setPluginPath().

QQmlEngine *LiveNodeEngine::qmlEngine() const

The QML engine to be used for loading QML components

See also setQmlEngine().

int LiveNodeEngine::rotation() const

Return the current rotation angle

See also setRotation().

void LiveNodeEngine::setFallbackView(QQuickView *fallbackView)

Sets fallbackView as the QQuickView for displaying QML Item based components, i.e., those not creating own windows.

See also fallbackView().

void LiveNodeEngine::setPluginPath(const QString &path)

Sets the pluginPath to path.

The pluginPath will be used to load QmlLive plugins

See also pluginPath() and ContentPlugin Example.

void LiveNodeEngine::setQmlEngine(QQmlEngine *qmlEngine)

Sets qmlEngine as the QML engine to be used for loading QML components

See also qmlEngine().

void LiveNodeEngine::setWorkspace(const QString &path, LiveNodeEngine::WorkspaceOptions options = NoWorkspaceOption)

Sets the current workspace to path. Documents location will be adjusted based on this workspace path. Certain features can be controled by passing options.

See also workspace() and WorkspaceOptions.

void LiveNodeEngine::usePreloadedDocument(const LiveDocument &document, QObject *object, QQuickWindow *window, const QList<QQmlError> &errors)

Allows to initialize active document with an instance preloaded beyond LiveNodeEngine's control.

This can be called at most once and only before a document has been loaded with loadDocument().

document is the source of the component that was used to instantiate the object. window should be either the object itself or the fallbackView(). errors (if any) will be added to log.

Note that window will be destroyed on next loadDocument() call unless it is the fallbackView(). object will be destroyed unconditionally.

void LiveNodeEngine::usePreloadedDocument(const QString &document, QQuickWindow *window, const QList<QQmlError> &errors)

This is an overloaded function provided for convenience. It is suitable for use with QQmlApplicationEngine.

Tries to resolve document against current workspace(). window is the root object. errors (if any) will be added to log.

QString LiveNodeEngine::workspace() const

Returns the current workspace path.

See also setWorkspace().

int LiveNodeEngine::xOffset() const

Returns the current x-offset of the window

See also setXOffset().

int LiveNodeEngine::yOffset() const

Returns the current y-offset of the window

See also setYOffset().

© 2019 Luxoft Sweden AB. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.