# VTK not being recognized by QtCreator in QML

**URL:** https://discourse.vtk.org/t/vtk-not-being-recognized-by-qtcreator-in-qml/14495
**Category:** Support
**Created:** [August 28, 2024, 9:35pm UTC](https://discourse.vtk.org/t/vtk-not-being-recognized-by-qtcreator-in-qml/14495 "2024-08-28T21:35:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![amireza007](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amireza007/32/9203_2.png) [@amireza007](https://discourse.vtk.org/u/amireza007)
#### Post date: [August 28, 2024, 9:35pm UTC](https://discourse.vtk.org/t/vtk-not-being-recognized-by-qtcreator-in-qml/14495/1 "2024-08-28T21:35:55Z")

</div>

Hello,

I’ve been struggling to include VTK into QML. I have installed VTK 9.3 through ninja, following the Kitware’s gitlab [docs](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/docs/build_instructions/build.md). I also have set env variables `QML_IMPORT_PATH` and `QML_IMPORT_PATH` to `VTKInstallation/lib/qml/vtk-9.3`. Everything seems to be working, **except QTCreator not identifying VTK qml Components**

Here is my CmakeLists.txt:

```cmake
cmake_minimum_required(VERSION 3.16)

project(hii VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick OpenGL)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

qt_standard_project_setup(REQUIRES 6.5)

qt_add_executable(apphii
    main.cpp
)
qt_add_qml_module(apphii
    URI hii
    VERSION 1.0
    QML_FILES
        Main.qml
)
set_target_properties(apphii PROPERTIES
    WIN32_EXECUTABLE TRUE
)
target_link_libraries(apphii
    PRIVATE Qt6::Quick
    ${QT_LIBRARIES}
    ${OPENGL_LIBRARIES}
    ${VTK_LIBRARIES}
)
include(GNUInstallDirs)
install(TARGETS apphii
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

```

Now, my `Main.qml` contains these VTK lines:

```qml
import VTK 9.3 # imports just fine!
...
VTKRenderWindow { # Unknown Component (M300)
      id: vtkwindow
      width: 400
      height: 400
    }

```

The code runs without any problems, nonetheless the qtcreator doesn’t seem to recognize the module’s components.  
BTW, the directory `VTKInstallation/lib/qml/vtk-9.3` contains `qmldir` and `plugins.qmltypes`:  
`qmldir` file:

```auto
import QtQuick.tooling 1.2

// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
// 'qmlplugindump -output $qmldir/VTK.9.1/plugins.qmltypes VTK 9.1 $qmldir'

Module {
    dependencies: ["QtQuick 2.0"]
    Component {
        name: "QQuickVTKInteractiveWidget"
        prototype: "QObject"
        exports: ["VTKWidget 9.1"]
        exportMetaObjectRevisions: [0]
        Property { name: "enabled"; type: "bool" }
        Signal {
            name: "enabledChanged"
            Parameter { name: "e"; type: "bool" }
        }
        Method {
            name: "sync"
            Parameter { name: "ren"; type: "vtkRenderer"; isPointer: true }
        }
    }
    Component {
        name: "QQuickVTKRenderItem"
        defaultProperty: "data"
        prototype: "QQuickItem"
        exports: ["VTKRenderItem 9.1"]
        exportMetaObjectRevisions: [0]
        Property { name: "renderWindow"; type: "QQuickVTKRenderWindow"; isPointer: true }
        Method { name: "sync" }
        Method { name: "init" }
        Method { name: "paint" }
        Method { name: "cleanup" }
    }
    Component {
        name: "QQuickVTKRenderWindow"
        defaultProperty: "data"
        prototype: "QQuickItem"
        exports: ["VTKRenderWindow 9.1"]
        exportMetaObjectRevisions: [0]
        Method { name: "sync" }
        Method { name: "init" }
        Method { name: "paint" }
        Method { name: "cleanup" }
        Method { name: "renderNow" }
        Method { name: "render" }
    }
}

```

`plugins.qmltypes` file:

```auto
import QtQuick.tooling 1.2

// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
// 'qmlplugindump -output $qmldir/VTK.9.1/plugins.qmltypes VTK 9.1 $qmldir'

Module {
    dependencies: ["QtQuick 2.0"]
    Component {
        name: "QQuickVTKInteractiveWidget"
        prototype: "QObject"
        exports: ["VTKWidget 9.1"]
        exportMetaObjectRevisions: [0]
        Property { name: "enabled"; type: "bool" }
        Signal {
            name: "enabledChanged"
            Parameter { name: "e"; type: "bool" }
        }
        Method {
            name: "sync"
            Parameter { name: "ren"; type: "vtkRenderer"; isPointer: true }
        }
    }
    Component {
        name: "QQuickVTKRenderItem"
        defaultProperty: "data"
        prototype: "QQuickItem"
        exports: ["VTKRenderItem 9.1"]
        exportMetaObjectRevisions: [0]
        Property { name: "renderWindow"; type: "QQuickVTKRenderWindow"; isPointer: true }
        Method { name: "sync" }
        Method { name: "init" }
        Method { name: "paint" }
        Method { name: "cleanup" }
    }
    Component {
        name: "QQuickVTKRenderWindow"
        defaultProperty: "data"
        prototype: "QQuickItem"
        exports: ["VTKRenderWindow 9.1"]
        exportMetaObjectRevisions: [0]
        Method { name: "sync" }
        Method { name: "init" }
        Method { name: "paint" }
        Method { name: "cleanup" }
        Method { name: "renderNow" }
        Method { name: "render" }
    }
}

```

Would someone please why QTCreator doesn’t know about the components?

Thank you very much in advance

Regards

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [September 1, 2024, 8:55pm UTC](https://discourse.vtk.org/t/vtk-not-being-recognized-by-qtcreator-in-qml/14495/2 "2024-09-01T20:55:59Z")

</div>

Hello,

Please, you can try taking a look at this: [Issue: Qt Creator can’t find custom C++ QtQuick Components, but compilation still works | Qt Forum](https://forum.qt.io/topic/121079/issue-qt-creator-can-t-find-custom-c-qtquick-components-but-compilation-still-works) and this: [qt - How do I import components into QtQuickDesigner? - Stack Overflow](https://stackoverflow.com/questions/69187321/how-do-i-import-components-into-qtquickdesigner).

best,

PC
