# QML Example

**URL:** https://discourse.vtk.org/t/qml-example/7247
**Category:** Development
**Created:** [November 22, 2021, 5:16pm UTC](https://discourse.vtk.org/t/qml-example/7247 "2021-11-22T17:16:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Jackson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael_jackson/32/61_2.png) [@Michael\_Jackson](https://discourse.vtk.org/u/Michael_Jackson)
#### Post date: [November 22, 2021, 5:16pm UTC](https://discourse.vtk.org/t/qml-example/7247/1 "2021-11-22T17:16:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Michael\_Jackson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael_jackson/32/61_2.png) [@Michael\_Jackson](https://discourse.vtk.org/u/Michael_Jackson)
#### Post date: [November 22, 2021, 7:34pm UTC](https://discourse.vtk.org/t/qml-example/7247/2 "2021-11-22T19:34:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Michael\_Jackson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael_jackson/32/61_2.png) [@Michael\_Jackson](https://discourse.vtk.org/u/Michael_Jackson)
#### Post date: [November 22, 2021, 9:45pm UTC](https://discourse.vtk.org/t/qml-example/7247/3 "2021-11-22T21:45:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![liushuya7](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liushuya7/32/1419_2.png) [@liushuya7](https://discourse.vtk.org/u/liushuya7)
#### Post date: [December 29, 2021, 8:39pm UTC](https://discourse.vtk.org/t/qml-example/7247/4 "2021-12-29T20:39:30Z")

</div>

I’m having the exact same issue.

```bash
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:

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

```

Or add it in the code:

```cpp
    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);

```

---

<div class="post-metadata">

### Author: ![edwardAllen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/edwardallen/32/4576_2.png) [@edwardAllen](https://discourse.vtk.org/u/edwardAllen)
#### Post date: [January 20, 2022, 1:56am UTC](https://discourse.vtk.org/t/qml-example/7247/5 "2022-01-20T01:56:32Z")

</div>

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

> **[GitHub - dezbracaty/QtVtk9.1: A qt vtk demo with vtk 9.1](https://github.com/dezbracaty/QtVtk9.1)**
>
> A qt vtk demo with vtk 9.1 . Contribute to dezbracaty/QtVtk9.1 development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![edwardAllen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/edwardallen/32/4576_2.png) [@edwardAllen](https://discourse.vtk.org/u/edwardAllen)
#### Post date: [January 20, 2022, 2:00am UTC](https://discourse.vtk.org/t/qml-example/7247/6 "2022-01-20T02:00:33Z")

</div>

In simple terms ， you should add this in cpp file

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

```

So qml part can find VTKPLUS and you can use

```auto
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.

---

<div class="post-metadata">

### Author: ![John.Stone](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@John.Stone](https://discourse.vtk.org/u/John.Stone)
#### Post date: [December 16, 2022, 5:06pm UTC](https://discourse.vtk.org/t/qml-example/7247/7 "2022-12-16T17:06:26Z")

</div>

Check out VTK\Examples\GUI\QML in this PR  
[https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/9763](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9763)
