# QML/VTK release build won't load or run

**URL:** https://discourse.vtk.org/t/qml-vtk-release-build-wont-load-or-run/15172
**Category:** Support
**Created:** [January 17, 2025, 8:03pm UTC](https://discourse.vtk.org/t/qml-vtk-release-build-wont-load-or-run/15172 "2025-01-17T20:03:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gzt036](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gzt036/32/5960_2.png) [@gzt036](https://discourse.vtk.org/u/gzt036)
#### Post date: [January 17, 2025, 8:03pm UTC](https://discourse.vtk.org/t/qml-vtk-release-build-wont-load-or-run/15172/1 "2025-01-17T20:03:08Z")

</div>

i have several issues here. first, when I enabled vtk\_build\_examples in cmake, but the generated vs2022 solution does not have any example directory to check, how does it work here.

secondly, i have hard time to run QML/vtk in release build, in debug build it works, but not release, and there is no clue what happens, even the simplest example won’t work。

> #include \<QtQml/QQmlApplicationEngine\>
> 
> #include \<QtQuick/QQuickWindow\>
> 
> #include \<QtGui/QGuiApplication\>  
> #include \<QtGui/QSurfaceFormat\>
> 
> #include \<QQuickVTKItem.h\>  
> #include \<QVTKRenderWindowAdapter.h\>
> 
> #include \<vtkActor.h\>  
> #include \<vtkConeSource.h\>  
> #include \<vtkPolyDataMapper.h\>  
> #include \<vtkRenderWindow.h\>  
> #include \<vtkRenderer.h\>
> 
> struct MyVtkItem : QQuickVTKItem  
> {  
> vtkUserData initializeVTK(vtkRenderWindow\* renderWindow) override  
> {  
> // Create a cone pipeline and add it to the view  
> vtkNew cone;
> 
> ```
> vtkNew<vtkPolyDataMapper> mapper;
> mapper->SetInputConnection(cone->GetOutputPort());
> 
> vtkNew<vtkActor> actor;
> actor->SetMapper(mapper);
> 
> vtkNew<vtkRenderer> renderer;
> renderer->AddActor(actor);
> renderer->ResetCamera();
> renderer->SetBackground(0.0, 1.0, 1.0);
> renderer->SetBackground2(1.0, 0.0, 0.0);
> renderer->SetGradientBackground(true);
> 
> renderWindow->AddRenderer(renderer);
> renderWindow->SetMultiSamples(16);
> 
> return nullptr;
> }
> 
> ```
> 
> };
> 
> int main(int argc, char\* argv)  
> {  
> QQuickVTKItem::setGraphicsApi();
> 
> #if QT\_VERSION \< QT\_VERSION\_CHECK(6, 0, 0)  
> QCoreApplication::setAttribute(Qt::AA\_EnableHighDpiScaling);  
> #endif
> 
> ```
> QGuiApplication app(argc, argv);
> 
> qmlRegisterType<MyVtkItem>("com.vtk.example", 1, 0, "MyVtkItem");
> 
> QQmlApplicationEngine engine;
> engine.load(QUrl(QStringLiteral("qrc:/testRelease4/qml/main.qml")));
> if (engine.rootObjects().isEmpty())
> return -1;
> 
> return app.exec();
> 
> ```
> 
> }

main.qml

> import QtQuick 2.9  
> import QtQuick.Window 2.2  
> import com.vtk.example 1.0
> 
> Window {  
> id: win  
> visible: true  
> width: 640  
> height: 640  
> title: qsTr(“Hello World”)
> 
> Rectangle {  
> anchors.fill: parent  
> color: “darkseagreen”  
> }
> 
> Rectangle {  
> id: r  
> border { width: 5; color: “steelblue” }  
> radius: 5  
> color: “hotpink”  
> anchors.fill: parent  
> anchors.margins: 100
> 
> ```
> MyVtkItem {
> id: vtk
> anchors.fill: parent
> anchors.margins: 5
> opacity: 0.7
> 
> }
> 
> ```
> 
> }
> 
> Rectangle {  
> anchors.leftMargin: parent.width/2  
> anchors.topMargin: parent.height/2  
> anchors.fill: parent
> 
> ```
> border { width: 5; color: "gold" }
> radius: 11
> color: "peachpuff"
> opacity: 0.8
> 
> ```
> 
> }  
> }

main.qml

with debug build it works fine, but with release build it says

QQmlApplicationEngine failed to load component  
qrc:/testRelease4/qml/main.qml:25:5: Cannot assign object to list property “data”

---

<div class="post-metadata">

### Author: ![xingjianzhang1997](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xingjianzhang1997/32/9778_2.png) [@xingjianzhang1997](https://discourse.vtk.org/u/xingjianzhang1997)
#### Post date: [February 2, 2025, 1:14pm UTC](https://discourse.vtk.org/t/qml-vtk-release-build-wont-load-or-run/15172/2 "2025-02-02T13:14:18Z")

</div>

兄弟，你解决这个问题了吗？我也一直被Cannot assign object to list property “data”这个问题困扰

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 5, 2025, 9:02am UTC](https://discourse.vtk.org/t/qml-vtk-release-build-wont-load-or-run/15172/3 "2025-02-05T09:02:19Z")

</div>

Hi @xingjianzhang1997

This is an english speaking forum.

Best,
