# Python Qt6 QML VTKRenderItem

**URL:** https://discourse.vtk.org/t/python-qt6-qml-vtkrenderitem/13626
**Category:** Support
**Tags:** python
**Created:** [March 24, 2024, 3:39pm UTC](https://discourse.vtk.org/t/python-qt6-qml-vtkrenderitem/13626 "2024-03-24T15:39:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kai](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kai](https://discourse.vtk.org/u/Kai)
#### Post date: [March 24, 2024, 3:39pm UTC](https://discourse.vtk.org/t/python-qt6-qml-vtkrenderitem/13626/1 "2024-03-24T15:39:22Z")

</div>

Hi :-),  
I want to use VTK with Pyside6 and QML. For C++ i found an example and with

```auto
QObject* topLevel = engine.rootObjects().value(0);
    QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel);
    window->show();

    QQuickVTKRenderItem* qquickvtkItem = topLevel->findChild<QQuickVTKRenderItem*>("ConeView");
    vtkRenderWindow *renderWindow = qquickvtkItem->renderWindow()->renderWindow();
    vtkRenderWindowInteractor *iRen = renderWindow->GetInteractor();
    vtkRenderer *renderer = qquickvtkItem->renderer();

```

on C++ side and

```auto
import QtQuick.Window
import VTK 9.3

Window {
    width: 600
    height: 600
    VTKRenderWindow {
        id: vtkwindow
        anchors.fill: parent
        VTKRenderItem {
         id: renderItem
         objectName: "ConeView"
         anchors.fill: vtkwindow
         renderWindow: vtkwindow
        }
    }
}

```

on QML Side, i get everything to use vtk.

But in Pyhon the VTKRenderWindow is just a QQuickItem and the Type QQuickVTKRenderItem does not exist.

So, how to use VTK in pyside6/qml apps ?

Thanks for help 🙂

---

<div class="post-metadata">

### Author: ![Kai](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kai](https://discourse.vtk.org/u/Kai)
#### Post date: [March 24, 2024, 5:28pm UTC](https://discourse.vtk.org/t/python-qt6-qml-vtkrenderitem/13626/2 "2024-03-24T17:28:44Z")

</div>

here is the link to the example : [classQQuickVTKRenderItem](https://vtk.org/doc/nightly/html/classQQuickVTKRenderItem.html). Sadly, The code does not work in Python ☹

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [March 25, 2024, 1:55pm UTC](https://discourse.vtk.org/t/python-qt6-qml-vtkrenderitem/13626/3 "2024-03-25T13:55:47Z")

</div>

Qt Quick allows you to create web-like UI on desktop. However, since VTK can now run in the web browser and you can run your C++ code (using webassembly) and Python code (for example using [pyodide](https://pyodide.org/)) natively in the web browser, too, you might consider cutting out Qt and use a web GUI framework instead (such as React or Angular).

Using Javascript framework instead of Qt for the GUI widgets may be very significant effort and most C++/Python on the web technologies are not mature yet, but the Qt company does not behave nicely (they make life of free Qt users increasingly more difficult; and licensing terms and costs for commercial Qt are unreasonable) and more and more users demand running their software natively in the browser. Therefore, web GUI should be seriously considered, especially for new projects and that can afford to use an evolving technology stack in the next few years.

---

<div class="post-metadata">

### Author: ![Tweister](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tweister/32/9225_2.png) [@Tweister](https://discourse.vtk.org/u/Tweister)
#### Post date: [August 29, 2024, 3:26am UTC](https://discourse.vtk.org/t/python-qt6-qml-vtkrenderitem/13626/4 "2024-08-29T03:26:06Z")

</div>

have an idea—why don’t we try creating a launcher? We could first use C++ to create a Qt application and register `QQuickVTKRenderItem` with Qt in advance. With this, the launcher would be completed, and then we could expose this launcher to Python-Embedding, allowing the launcher to execute commands from Python. Wouldn’t this also allow PyQt or PySide6 to run a QtQuick interface while achieving compatibility with VTK? My C++ coding skills are very limited, but I think this could be feasible. Perhaps this GitHub project might offer more inspiration: [GitHub - skywind3000/PyStand: 🚀 Python Standalone Deploy Environment !!](https://github.com/skywind3000/PyStand/tree/master).

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 29, 2024, 11:14am UTC](https://discourse.vtk.org/t/python-qt6-qml-vtkrenderitem/13626/5 "2024-08-29T11:14:56Z")

</div>

3D Slicer, MeVisLab, maybe even MITK all use PythonQt to embed Python in a VTK/Qt application. Everything works very nicely. The drawback of PythonQt that the application is C++ first, and Python is embedded. Some Python developers don’t like this. Also, PythonQt is not as popular as PyQt and PySide.
