Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. VTK integration issue in QML at runtime on Windows
Forum Updated to NodeBB v4.3 + New Features

VTK integration issue in QML at runtime on Windows

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 328 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Winz 0
    wrote on last edited by
    #1

    I don’t have any problems on linux, but on windows, when I instantiate a simple QQuickVTKItem item, it compiled well but I get the following error at runtime:

    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}
    )
    
    1 Reply Last reply
    0
    • W Offline
      W Offline
      Winz 0
      wrote on last edited by
      #2

      This error appears because I was running a Debug target with a Release version of VTK. No problem if you link a Debug app with a Debug VTK or Release app with a Release VTK.

      1 Reply Last reply
      0
      • W Winz 0 has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved