I don’t have any problems on linux, but on windows, when I instantiate a simple QQuickVTKItem item, I get the error:
QQmlApplicationEngine failed to load component
qrc:/qt/qml/minVtkQml/Main.qml:10:5: Cannot assign object to list property “data”
Has anyone ever had the problem? ? I can’t find a way to debug
win10/msvc2019/ninja/Qt6.7.2 and Qt6.7.3 and VTK 9.3 compiled with -DVTK_GROUP_ENABLE_Qt:STRING=YES
main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickVTKItem.h>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
qmlRegisterType<QQuickVTKItem> ("Test", 1, 0, "Vtk");
QQmlApplicationEngine engine;
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("minVtkQml", "Main");
return app.exec();
}
Main.qml
import QtQuick
import Test 1.0
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Vtk{
}
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(minVtkQml VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.7 REQUIRED COMPONENTS Quick)
set(VTK_DIR "../VTK/bin/lib/cmake/vtk-9.3/")
find_package(VTK REQUIRED)
qt_standard_project_setup(REQUIRES 6.7)
qt_add_executable(appminVtkQml
main.cpp
)
qt_add_qml_module(appminVtkQml
URI minVtkQml
VERSION 1.0
QML_FILES
Main.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appminVtkQml PROPERTIES
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appminVtkQml
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
target_link_libraries(appminVtkQml PRIVATE
Qt${QT_VERSION_MAJOR}::Quick
${VTK_LIBRARIES}
)
vtk_module_autoinit( TARGETS appminVtkQml MODULES ${VTK_LIBRARIES} )
include(GNUInstallDirs)
install(TARGETS appminVtkQml
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)