Hi! I built VTK 9.1 on windows 10 with GUISupportQtQuick enabled and QT 5. The build is done without any error. However, I am not able to import VTK in qml. Here is the error I get:
I have defined the environment variable QML2_Import_PATH to where qmldir directory.
Any help would be much appreciated.
Thanks,
Parisa
set(VTK_DIR "C:/VTK9/${BUILD_ARCH}/VTK/${CMAKE_BUILD_TYPE}")
set(VTK_BIN ${VTK_DIR}/bin)
message("VTK Dir: ${VTK_DIR}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${VTK_DIR}/lib/cmake/vtk-9.1")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${VTK_DIR}/lib/cmake/vtk-9.1")
set(QML_IMPORT_PATH_VTK "${VTK_DIR}/lib/qml/${CMAKE_BUILD_TYPE}")
find_package(VTK
COMPONENTS
CommonCore
CommonColor
GUISupportQt
GUISupportQtQuick
IOImage
IOGeometry
IOPLY
FiltersModeling
ImagingColor
ImagingGeneral
InteractionImage
InteractionStyle
InteractionWidgets
RenderingAnnotation
RenderingLabel
REQUIRED)
set(VTK_LIBRARIES
VTK::CommonCore
VTK::CommonColor
VTK::GUISupportQt
VTK::GUISupportQtQuick
VTK::IOImage
VTK::IOGeometry
VTK::IOPLY
VTK::FiltersModeling
VTK::ImagingColor
VTK::ImagingGeneral
VTK::InteractionImage
VTK::InteractionStyle
VTK::InteractionWidgets
VTK::RenderingLabel
VTK::RenderingAnnotation
)
endif()
add_dll(NAME ...
NAMESPACE ...
LINK_LIBRARIES
...
${VTK_LIBRARIES}
SOURCES
${_sources}
${_headers}
${_other}
)
It can maybe help you
I figured out what was missing based on:
GitHub - dezbracaty/QtVtk9.1: A qt vtk demo with vtk 9.1
After adding the following lines to main.cpp I was able to import VTK and render 3D volume:
qmlRegisterType(“VTK”, 9, 1, “VTKRenderWindow”);
qmlRegisterType(“VTK”, 9, 1, “VTKRenderItem”);
qmlRegisterType(“VTK”, 9, 1, “VTKWidget”);
In fact , there. are many ways to fix this . You can use qmlResisterType to let qt know this object , and you can make a qml plugin to let qt know this object too , There are other methods, mainly you can let qt know this type。the second way is in vtk-example.
And i am the author of the project.