QML Example

Is there an example that uses the newer QML support besides the test cases? I’m having some issues getting a basic application (based off of the test applications) to actually run.

I’m getting the error:

W 4674031 qrc:/qml/components/VTK/VisualizationView.qml:9:1: module “VTK” is not installed qrc:/qml/components/VTK/VisualizationView.qml(9):

when I try to “import VTK 9.1” in my QML file? Any ideas

Thanks

Are there any issues embedding the QQuickVtkView thing inside a QSplitView? Seems that the only way that I can get anything to show in my application window is if the vtk render area takes up the entire Window area.

I’m having the exact same issue.

QML2_IMPORT_PATH: QList("/home/josh/qt_tutorial_ws/3d_vtk_qml/src/build", "qrc:/qt-project.org/imports", "/home/josh/VTK-9.1.0/build/lib/qml", "/home/josh/Qt/6.2.2/gcc_64/qml")
QQmlApplicationEngine failed to load component
qrc:/main.qml:6:1: module "VTK" is not installed
Segmentation fault (core dumped)

After adding this to the environment path in the terminal, it worked:

export QML2_IMPORT_PATH=/home/josh/VTK-9.1.0/build/lib/qml

Or add it in the code:

    QQmlApplicationEngine engine;
    engine.addImportPath("/home/josh/VTK-9.1.0/build/lib/qml"); # <---- add here
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    engine.load(url);

You can see this project and the things you asked are in it .

In simple terms , you should add this in cpp file

    qmlRegisterType<QQuickVTKRenderWindow>("VTKPLUS", 9, 1, "VTKRenderWindow");

So qml part can find VTKPLUS and you can use

import VTKPLUS 9.1

Or you can write a plugin for qt like demo in vtk examples , but that approach is a bit more complicated.

Check out VTK\Examples\GUI\QML in this PR
https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9763