VTK  9.3.20240425
Public Member Functions | Protected Slots | List of all members
QQmlVTKPlugin Class Reference

Plugin class to expose a VTK C++ module to QML applications. More...

#include <QQmlVTKPlugin.h>

Inherits QQmlExtensionPlugin.

Public Member Functions

 QQmlVTKPlugin ()=default
 Constructor.
 
 ~QQmlVTKPlugin () override=default
 Destructor.
 
void registerTypes (const char *uri) override
 Register QML types provided by VTK.
 
void initializeEngine (QQmlEngine *engine, const char *uri) override
 Initialize the extension using the QQmlEngine.
 

Protected Slots

void cleanup ()
 Destroy any singleton instances that were created during initializeEngine.
 

Detailed Description

Plugin class to expose a VTK C++ module to QML applications.

QQmlVTKPlugin registers various VTK C++ classes as QML types so that QtQuick applications can directly import and use these types from QML.

Importing the VTK module in QML

As part of VTK's compilation process, it would compile and install a qmldir file that provides the module definition and relevant plugin information required by QML to load VTK. To load the plugin, set the environment variable QML2_IMPORT_PATH to the path of the directory containing the qmldir file.

# /projects/Import has a sub-directory VTK.9.0/qmldir
$ export QML2_IMPORT_PATH=/projects/Import

Once the import path is set correctly, the module can be imported in the .qml file as follows:

import VTK 9.0

Registered types

The C++ classes exposed to QML and their associated typenames are as follows:

VTK C++ class QML type
QQuickVTKRenderWindow VTKRenderWindow
QQuickVTKRenderItem VTKRenderItem
QQuickVTKInteractiveWidget VTKWidget

Versioning

The VTK QML module follows the version number of the VTK source tree. For example, if compiled against VTK 9.0.x, the VTK module version will be 9.0

Definition at line 52 of file QQmlVTKPlugin.h.

Constructor & Destructor Documentation

◆ QQmlVTKPlugin()

QQmlVTKPlugin::QQmlVTKPlugin ( )
default

Constructor.

◆ ~QQmlVTKPlugin()

QQmlVTKPlugin::~QQmlVTKPlugin ( )
overridedefault

Destructor.

Member Function Documentation

◆ registerTypes()

void QQmlVTKPlugin::registerTypes ( const char *  uri)
override

Register QML types provided by VTK.

◆ initializeEngine()

void QQmlVTKPlugin::initializeEngine ( QQmlEngine *  engine,
const char *  uri 
)
override

Initialize the extension using the QQmlEngine.

See also
cleanup

◆ cleanup

void QQmlVTKPlugin::cleanup ( )
protectedslot

Destroy any singleton instances that were created during initializeEngine.

See also
initializeEngine

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